I am trying to redirect all pages to /uk
apart from the home page and the /uk
page but I get localhost redirected you too many times
when it loads the /uk
page. I thought !^/uk$
would solve this. Any help is greatly appreciated
Here is my code in the .htaccess
file;
# Add your own rules here.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/$ [NC]
RewriteCond %{REQUEST_URI} !^/uk$ [NC]
RewriteCond %{HTTP_COOKIE} !cookieConfirmed=1;? [NC]
RewriteRule . /uk [L,R=301]
</IfModule>
These should work:
RewriteCond %{REQUEST_URI} !^/$ [NC]
RewriteCond %{REQUEST_URI} !^/uk/?$ [NC]
RewriteRule ^(.*) /uk [L,R=301]
Maybe you added a slash to all URLs so the too many redirects occurs? So I made a / at the end optional.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.