.htaccess redirect loop with RewriteCond
.htaccess redirect loop with RewriteCond
I am trying to redirect a specific page
http://www.my.website/admin
http://www.my.website/admin
to
https://my.website/admin/
https://my.website/admin/
using this code:
Redirect 301 /admin/ https://my.website/admin/
but it keeps looping and I can not find out why as I have specified the condition for 'www' not to be present.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %HTTP_HOST ^www.tci.rocks$ [NC]
RewriteRule ^admin/?$ https://my.website/admin/ [L,R=301]
</IfModule>
# BEGIN WithoutWWW
RewriteEngine on
RewriteCond %HTTPS !=on
RewriteCond %HTTP_HOST ^www.(.+)$ [NC]
RewriteRule ^ https://%1%REQUEST_URI [R=301,L]
# END WithoutWWW
# BEGIN YOURLS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^.*$ /yourls-loader.php [L]
</IfModule>
# END YOURLS
<IfModule mod_autoindex.c>
Options -Indexes
</IfModule>
How can i make this .htaccess stop looping ??
1 Answer
1
Use instead:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %HTTP_HOST ^www.my.website$ [NC]
RewriteRule ^admin/?$ https://my.website/admin/ [L,R=301]
</IfModule>
Ok, no problem !
– Croises
Sep 14 '18 at 9:46
my test are showing no joy.
– Mau
Sep 17 '18 at 3:30
i will now edit the question to reflex 100% what is on the live server, temporarily. then when all is clear, i will revert back to generic. thank you
– Mau
Sep 17 '18 at 3:31
What exactly is your problem or error message?
– Croises
Sep 18 '18 at 11:42
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy
i will choose yours as final answer next week when i test it. thank you
– Mau
Sep 14 '18 at 7:39