Forum Moderators: phranque

Message Too Old, No Replies

Beginner Redirect Question

         

The_Saw

7:42 am on Jan 20, 2005 (gmt 0)

10+ Year Member



I do apologize for posting this, but I've been looking through the forums and trying some things with my .htaccess file that haven't been working at all.

All I am trying to do is make it so that any request for the site at [mysite.com...] is redirected to [mysite.com...]

Any help would be greatly appreciated, and once again, sorry for posting such an elementary question.

RobsterUK

9:57 am on Jan 20, 2005 (gmt 0)

10+ Year Member



If you have root access on your server you can add the following to the configuration file for your site.

ServerAlias domain.com

The_Saw

12:50 am on Jan 21, 2005 (gmt 0)

10+ Year Member



Unfortunately I do not have root access to the server, it is virtual. Is there anything I can do with the .htaccess file to acheive this result?

jdMorgan

12:59 am on Jan 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The_Saw,

Welcome to WebmasterWorld!

> and trying some things with my .htaccess file that haven't been working at all.

Please post your code and test results as a basis for discussion.

Also, our forum charter [webmasterworld.com] contains links to documentation that may help you get started.

Jim

The_Saw

5:33 am on Jan 21, 2005 (gmt 0)

10+ Year Member



Thanks for the help, but I think I've got it working using this code:

RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.mydomain\.com [NC]
RewriteCond %{HTTP_HOST}!^$
RewriteRule ^/(.*) [mydomain.com...] [L,R]

One odd behavior though is that if I type 'mydomain.com/dir' into the browser, it re-directs successfully to 'www.mydomain.com/dir'. However, if while I'm there I erase the 'www.', and go to that destination, the redirect does not take place, I go to 'mydomain.com/dir'. But if I then replace '/dir' with '/dir2' and do not add a 'www.', when I navigate to that page the redirect works again, and I am sent to the location with the 'www.' present.

I assume this has something to do with Apache not handling the reloading of a page this way the same way it handles other requests, or is there something else I am missing?

Thanks again!

jdMorgan

4:41 pm on Jan 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Apache not handling the reloading of a page

Apache won't 'handle the reloading of a page' if the request is not sent to your server... Flush your browser cache (and any other cache you may have, such as your local-network proxy cache) before *each* test of any access-control code. Alternatively, set your browser so that it does not cache pages from your domains while you are testing.

Jim