homepage Welcome to WebmasterWorld Guest from 54.227.41.242
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
From www to no www.
.htaccess mod
FuzzyLogik




msg:3207444
 12:25 am on Jan 4, 2007 (gmt 0)

I found this code to turn NON-www into WWW, but I don't want to use www.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ [yoursite.com...] [L,R=301]

How would I make this so that if you go to

[mysite.com...]
it'll go to
[mysite.com?...]

 

jdMorgan




msg:3207450
 12:44 am on Jan 4, 2007 (gmt 0)

Based on the function you know that it implements, and the domains shown in that example, how do you think it should be modified?

Jim

FuzzyLogik




msg:3207460
 1:11 am on Jan 4, 2007 (gmt 0)

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.yoursite.com [NC]
RewriteRule ^(.*)$ [yoursite.com...] [L,R=301]

?

That does work somewhat, but when I go to a subdir,
[mysite.com...]

it doesn't change it.

Does that matter for SEO reasons? I think I would prefer it if it changed.

jdMorgan




msg:3207490
 1:48 am on Jan 4, 2007 (gmt 0)

The code, which you coded correctly enough, should work for any file in any subdirectory.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^ww[b]w\.e[/b]xampl[b]e\.c[/b]om [NC]
RewriteRule (.*) http://example.com/$1 [L,R=301]

Literal periods in regular-expressions patterns must be escaped by preceding them with a "\". Otherwise, they take the regular-expressions token meaning of "any single character." Also, it is not necessary to ^start or end$ -anchor a ".*" pattern standing alone. Your code should have worked anyway. So...

If you have not done so already, flush your browser cache (delete IE Temporary Internet Files) before testing any change to your .htaccess code. Otherwise, your browser may show you a response cached before the change, and continue to do so for days, unless you force a page reload or overwrite that cache entry with something newer just by using your browser on other sites.

For more (general) information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved