Stefaan
Stefaan

Reputation: 182

.htaccess redirect: www not working

I want to redirect a domain alias to a specific page on my site. I use this code:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^afdekfolie.be$ [NC]
RewriteRule ^(.*)$ http://www.technosales.be/wordpress/afdekfolie/ [R=301,L]

This works when entering afdekfolie.be as the alias, but not when entering www.afdekfolie.be

How do I make this work?

Thanks, Stefaan

Upvotes: 0

Views: 38

Answers (1)

Cheery
Cheery

Reputation: 16214

Because you are asking this rule to work for the host starting with afdekfolie...

Try this one

RewriteCond %{HTTP_HOST} ^(www\.)?afdekfolie\.be$ [NC]

Or you can break it into two rules

RewriteCond %{HTTP_HOST} ^afdekfolie\.be$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.afdekfolie\.be$ [NC]

ps: how is this related to the php tag?

Upvotes: 2

Related Questions