I’m trying to redirect/rewrite this search url with either 2 or 3 query parameters but I keep getting “This page isn’t redirecting properly”, when I remove QSD it works but appends the query string to the end of the URL so what is going on?
RewriteEngine On
# Ensure the base directory is correctly set
RewriteBase /w/sfj/www2/
# Prevent rewriting for existing files and directories
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^test$ index.html [L]
# Redirect query parameters to friendly URLs
RewriteCond %{QUERY_STRING} ^q=([^&]+)&location=([^&]+)&page=([^&]+)$ [NC]
RewriteRule ^search.php$ search/%1/%2/%3 [R=301,L,NE,QSD]
RewriteCond %{QUERY_STRING} ^q=([^&]+)&location=([^&]+)$ [NC]
RewriteRule ^search.php$ search/%1/%2 [R=301,L,NE,QSD]
# Rewrite friendly URLs to internal script
RewriteRule ^search/([^/]+)/([^/]+)$ search.php?q=$1&location=$2 [L,QSA]
RewriteRule ^search/([^/]+)/([^/]+)/([^/]+)$ search.php?q=$1&location=$2&page=$3 [L,QSA]
Tried it before without QSD but adds query to the end of the URL
John is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.