Mau
Mau

Reputation: 1313

.htaccess redirect loop with RewriteCond

I am trying to redirect a specific page

http://www.my.website/admin

to

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 ??

Upvotes: 0

Views: 82

Answers (1)

Croises
Croises

Reputation: 18671

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>

Upvotes: 1

Related Questions