Question

I need to match all urls that DO have mydomain.com in them AND DO NOT contain either /admin/ or ?page=
i tried the following:

RedirectRule (mydomain.com)(^(?!.*(/admin|\?page=)))  http://www.mydomain.com?page=666

the negative part works well:

RedirectRule ^(?!.*(/admin|\?page=))  http://www.mydomain.com?page=666  

but mydomain is an alias of some other domain and i want the redirect only for the alias (mydomain.com)

I'm using this as a redirect rule in an iirf.ini file (supports htaccess syntax).

thanx in advance and have a nice day :-)

Was it helpful?

Solution

Try the following .htaccess rules

#has mydomain.com
RewriteCond %{HTTP_HOST} mydomain\.com$ [NC] 
#not admin
RewriteCond %{REQUEST_URI} !^/admin/ [NC] 
#not page=
RewriteCond %{QUERY_STRING} !(^|&)page= [NC] 
#redirect
RewriteRule ^ http://www.mydomain.com?page=666 [R=301,L]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top