PDA

View Full Version : redirect from main URL



dharrison
03-22-2008, 05:25 AM
Hi all

I have a problem with one of my recent websites. Basically if you type in www.itsdomainname.com (http://www.itsdomainname.com) we just get a blank screen. its actual homepage is found at www.itsdomainname.com (http://www.itsdomainname.com/index.html)

Would a simple 301 redirect remedy this problem? I have had to create an .htaccess file which so far consists of




SecFilterEngine Off
SecFilterScanPOST Off



Is this anything to do with the problem I am experiencing?

Any help gratefully received. Thanks.

thindenim
03-22-2008, 08:27 AM
Hi there,

Do you mean you need requests for domain.com to go to www . domain .com?

If so, the following should do the trick: -

RewriteEngine On

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

dharrison
03-23-2008, 07:45 AM
I wrote that wrong didn't I? I meant www.mydomainname.com needs to redirect to www.mydomainname.com/index.html

I shall try that thindenim - Thanks.

wige
03-24-2008, 09:49 AM
The following should work:


RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^/$ http://www.domain.com/index.html [R=301,L]This rule is only activated when "/" (the site root) is requested, and redirects the user to "/index.html". This needs to be fairly specific, because otherwise, the rule could be triggered when subfolders are requested. If you want this rule triggered for all subfolders as well, use the following:


RewriteCond %{REQUEST_URI} ^.*/$
RewriteRule ^(.*)/$ http://www.domain.com$1/index.html [R=301,L]