Forum Moderators: phranque

Message Too Old, No Replies

Redirect non www

Using .htaccess

         

hunkydory

11:28 am on Aug 22, 2005 (gmt 0)

10+ Year Member



Hello!

I have been looking for a way to re-direct traffic from: http://example.com to http://www.example.com . I have found many different scripts doing this and was wondering which is the most effective way?

Thx for any help

[edited by: jdMorgan at 6:47 pm (utc) on Aug. 22, 2005]
[edit reason] Examplified. [/edit]

jdMorgan

8:01 pm on Oct 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hutchins13,

> ...change the "0" (zero) used to spell "0ptions" to an "O", "Options".

Well-spotted! I have corrected those two posts to prevent future problems -- I hate to see 'bad code' propagating because it's copied from here. My apologies to anyone affected by this error.

Jim

[edited by: jdMorgan at 8:10 pm (utc) on Oct. 31, 2005]

jdMorgan

8:09 pm on Oct 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



BradStevens,

In order to work, the modules used by the code must be installed and enabled, you must have privileges to use them, your code has to be correct, and your code has to be located in the right place, so that it gets executed for the request that you wish to rewrite or redirect.

Check your access log and error log -- even in the absense of any error message -- to see if there's any clue as to what might be wrong.

You can test mod_rewrite in a lot ways; Try putting an invalid mod_rewrite directive in your code to make sure the server is executing the code... It should throw an error if so. Try simplifying the code to something basic like
RewriteRule ^foo\.html$ http://www.example.com/bar.html [R=301,L]
Then request "foo.html" from your server, and you should be redirected to "bar.html", whether it exists or not.

Check your httpd.conf file to be sure that there is no code there is interfering with your rules; Either mod_rewrite, mod_proxy, or mod_alias code could rewrite, redirect, or proxy the request away before your code in .htaccess gets a chance to run.

These are just a few common problems beyond simple code errors -- stuff to check, anyway.

Jim

This 32 message thread spans 2 pages: 32