twan
twan

Reputation: 2659

Infinite redirect loop htaccess

I want to redirect every www. url to an url without www. using .htaccess but I am getting an infinite redirect loop.

Does anyone see what I'm doing wrong?

RewriteEngine  on
RewriteBase /_extern/pod/
RewriteCond %{HTTP_HOST} !^site\.nl/_extern/pod/$ [NC]
RewriteRule ^(.*)$ http://site.nl/_extern/pod/$1 [R=301,L]

#Indexes uitzetten
Options -Indexes

#Cross site access toestaan
Header set Access-Control-Allow-Origin "*" 
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type" 

#POD
DirectoryIndex index.php

RewriteRule         ^info/(.*).html catlisting.php?alias=$1 [L]
RewriteRule         ^nieuws/(.*).html nieuws.php?alias=$1 [L]
RewriteRule         ^(.*).html content.php?alias=$1 [L] 

site.nl/extern/pod/ Needs to be the root for all urls.

My basetag if that is relevant:

<base href="http://site.nl/_extern/pod/">

Upvotes: 1

Views: 99

Answers (1)

Joe
Joe

Reputation: 4897

It looks to me you're being very specific to a URL with certain directories, try using the following instead:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]

So this should remove WWW from all of your URLs as well as sub-directories

Upvotes: 2

Related Questions