I have the following rewrite rules but every time I restart Apache they prevent apache from restarting and FAIL.
One error was…
Starting httpd: Syntax error on line 82 of /var/www/vhosts/current_release/url-rewrite-maps/catchall.txt: RewriteRule: cannot compile regular expression
'^/ProductDetails\.aspx\?PromotionID\(.*)\&id\(.*)$' [FAILED]
RewriteRule ^/ProductSearch\.aspx\?Ntt\=(.*)\&N\=(.*)$ catalogsearch/result/?q=$2 [R=302,L,NC]
#old search redirect to search
RewriteRule ^/ProductSearch\.aspx\?viewall\=1\&N\=(.*)$ productsearch.aspx?N=$1 [R=302,NC]
#viewall with N parameter to another redirect rule for URL with N= value only
RewriteRule ^/ProductSearch\.aspx\?(Ne|No)\=(.*)\&N\=(.*)$ productsearch.aspx?N=$3 [R=302,NC]
#url with Ne OR No param and N= to productsearch.aspx redirect on URLs with N= only
RewriteRule ^/ProductDetails\.aspx\?PromotionID\=(.*)\&id\=(.*)$ productdetails.aspx?id=$2 [R=302,NC]
#should pass the PID into the ID= and redirect from there
RewriteRule ^/ProductDetails\.aspx\?id\=(.*)\&RSSLINK\=(.*) productdetails.aspx?id=$1 [R=302, NC]
Thanks,
Brad
This is because what you are trying to do is invalid. You can’t access the query string through the regexp match pattern — its not allowed. You have to use a rewrite condition to pick up the query string, for example:
You can create a ladder of these and put a catchall at the bottom
This will do an internal redirect of any request that wasn’t matched by the previous rules to your catch all. The condition is there to stop an infinite redirection loop.