Forum Moderators: bakedjake

Message Too Old, No Replies

.htaccess, httpd.conf? Redirection to "www"

         

Tardo

11:30 am on May 21, 2003 (gmt 0)

10+ Year Member



Hello,

I NEED to make my domains put automatically the "www" and the last "/" when any page of the site without them is requested.

The same that happens everywhere on php.net. i.e:
[php.net...]

I think that what I have to do is to put a redirection to 301... but not sure of how I can do it.

I also thought it would be a matter of "httpd.conf", but my hoting provider told me that it can only be done by .htaccess. (though other servers as cobalt can do it themselves). It will be boring editting every htaccess of every domain, but if that's the way of doing it... it will have to be done.

I'm not sure if httpd.conf or htaccess, but anyway, I hope you can throw me a smalll light (or an url) on all this subject.

Thanks for your time!
Tardo

eaden

11:54 am on May 21, 2003 (gmt 0)

10+ Year Member



Put in either,
RedirectPermanent / [your...] domain.com/

Tardo

8:43 pm on May 21, 2003 (gmt 0)

10+ Year Member



I have already tried it.

The headers seem to be ok,

But I can't see any page when typing any url under that domain, even the domain name (with or without "www")

Thanks for your answer. :)

jeremy goodrich

8:46 pm on May 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member


I use the following to redirect non -www requests to www.domain requests:

RewriteEngine On
RewriteCond %{HTTP_host}!^www\.site-url-here\.com$
RewriteRule ^(.*)$ http://www.site-url-here.com/$1 [R=permanent,L]

That's it, in the .htaccess file.

Tardo

11:48 pm on May 21, 2003 (gmt 0)

10+ Year Member



I think that should work (even more... I've seen your site and it works), but I get an ALERT, and a 500 Server Error...
so any page is shown.

(I've tryed it on two different servers, and I'm going to try it on a third one more)

This is the final part of the alert, from the apache error_log:

RewriteCond: bad argument line '%{HTTP_HOST}!^www.my-domain-name.my-tld$'

Thanks for your answer, though.

Tardo

4:02 am on Jun 1, 2003 (gmt 0)

10+ Year Member



To those who find PROBLEMS with the solution sent by Jeremy:

Just add:

Options +FollowSymlinks

On your .htaccess, the whole code would be like this:


Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_host}!^www\.site-url-here\.com$
RewriteRule ^(.*)$ http://www.site-url-here.com/$1 [R=permanent,L]

VERY SPECIAL THANKS TO CARLITUS!

PS: You can find this same question on the domain names forum:
[webmasterworld.com...]