ColarM
11-15-2007, 05:07 PM
How can i config my site so it add www. even if url was typed without it?
![]() | View Full Version : Always add www. to url in browser. ColarM 11-15-2007, 05:07 PM How can i config my site so it add www. even if url was typed without it? the_pm 11-15-2007, 05:15 PM Perhaps this will help :) http://www.bignosebird.com/apache/a14.shtml HostingDeals 11-15-2007, 06:42 PM the_pm, very nice resource. I was going to suggest mod_rewrite myself but the site includes everything needed on one page. :) the_pm 11-16-2007, 12:47 AM the_pm, very nice resource. I was going to suggest mod_rewrite myself but the site includes everything needed on one page. :)That link certainly saved me a lot of typing :D ColarM 11-16-2007, 09:58 AM Getting error "The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete." I dont find file httpd.conf anywhere on my ftp, i use hosting from namecheap. the_pm 11-16-2007, 10:22 AM Getting error "The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete." I dont find file httpd.conf anywhere on my ftp, i use hosting from namecheap.Unless you own your own server, you won't be able to modify the httpd.conf file. Instead, create a new file called .htaccess (note the lack of any characters before the period), and place your rewrite script in there. Place the file in your Web root, and you should be good to go. DephNet[Paul] 11-16-2007, 01:09 PM There are a couple ways that you can force www.domain.tld instead of domain.tld. One of them has been mentioned and thats mod_rewrite. The other is to use a scripting language, my personal choice is PHP, to detect the host name you are using and to redirect you to the correct hostname. I myself have used both and find that mod_rewrite has more features but it is also more prone to breaking. Paul Fixago 11-16-2007, 03:29 PM http://www.bignosebird.com/apache/a14.shtml Man, BNB is so old school! I remember reading stuff on that site when SSI and CGI/Perl were still being used. Oh, and to add WWW to the domain: Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^domain.com$ [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] Just add that to your .htaccess file. Never had a problem with this "breaking" either. This is one of the first things you should do on your sites, force the WWW. Take note of the R=301 too, I don't like BNB's example because it's a standard 302 (temporary) redirect. ColarM 11-16-2007, 03:39 PM Unless you own your own server, you won't be able to modify the httpd.conf file. Instead, create a new file called .htaccess I did first code did not work on namecheap hosting. Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^domain.com$ [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] Just add that to your .htaccess file. Never had a problem with this "breaking" either. This is one of the first things you should do on your sites, force the WWW. Take note of the R=301 too, I don't like BNB's example because it's a standard 302 (temporary) redirect. Works great, btw whats the disadvantage with temporary redirect? arbet 11-16-2007, 05:19 PM Temporary redirects don't transfer your Search engine ranks to the new page. For example: Your page hosting-plans.html is ranked 1st for the keyword 'hosting' on google, and life is great! Let's say you wanted to redesign the site, and hosting-plans.html content is going to be placed inside hosting-offers.html If you issue a 302 redirect, all google results keep displaying your original page. However, if you use 301 redirect, your search engines listings will be updated. So if you decide to delete the old page later, your rankings will be preserved in the new page. I hope this helps. |