Search code examples
.htaccessjoomla

.htaccess Redirect all subpages except one


I redirected Joomla frontpage to different domain using .htaccess:

RewriteRule !^(media|administrator) http://newdomain.pl%{REQUEST_URI} [L,R=301]

It works.

I need one URL to exclude from the redirection, in order to gather stats from newsletter component. So I tried this:

RewriteCond %{REQUEST_URI} !index.php?option=com_mycomponent&ctrl=stats
RewriteRule !^(media|administrator) http://newdomain.pl%{REQUEST_URI} [L,R=301]

But it doesn't work, although I clear browser cache many times. Any ideas?


Solution

  • USE THE_RQUEST srever-varibale not REQUEST_URI if you want to match all part of request so change this :

    RewriteCond %{REQUEST_URI} !index.php?option=com_mycomponent&ctrl=stats
    

    With this :

    RewriteCond %{THE_REQUEST} !index\.php\?option=com_mycomponent&ctrl=stats