i have .htaccess
in which i want 301 redirect
.So when I add 301 redirect code in .htaccess
it works fine but i can not login to my backend.But if I remove this code it works fine.I just want it to work in frontend but now because of this code my I cannot login into backend.
Here is the CODE
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
now i want if else condition or something which helps me to solve this error which works only for frontend of my open cart site and admin remains as it is without redirection.
Always preceded all my code with RewriteEngine On
. These directives tells to proceed to the RewriteRule
if not an admin/* area:
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{REQUEST_URI} !^admin/
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
This code must exclude all the admin/* and *.(ico|gif|jpg|jpeg|png|js|css) URLs:
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{REQUEST_URI} !^admin/
RewriteCond %{REQUEST_URI} !\.(ico|gif|jpg|jpeg|png|js|css)$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Anyway, you can still try to redirect all the non-www to www URLs with this code but do not forget add some www.
in your "config.php" admin map:
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
And always clear your browser cache or use a different one before checking because once the browser has been redirected [R=301]
permanently to the wrong address, if you then go on to alter the wonky rule, your browser will still be redirected to the old address because your browser is still caching it.