...

View Full Version : 301 redirect



b_hole
08-26-2007, 09:16 AM
Hi,

I'm currently using the following .htaccess code:

RewriteEngine on
RewriteBase /
ReWriteRule \.htaccess [F]
RewriteRule ^([a-zA-Z0-9\/\-]+)$ index.php?url_path=$1
And I'd like to add a 301 redirect to move all access from http://example.com to http://www.example.com. How can I do it, keeping the current rewrite rule?

Thanks.

ess
08-26-2007, 10:55 AM
add the following just after RewriteBase /

RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

or the following

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

Cheers,
Ess

b_hole
08-26-2007, 11:56 AM
Thanks a lot :)

b_hole
09-02-2007, 01:37 PM
I have a problem with this. I have a website with several sub domains, and using this htaccess code it's impossible to enter subdomains.
Is there a workaround? Maybe defining several string (subdomains) to exclude?

Thanks again.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum