homepage Welcome to WebmasterWorld Guest from 54.196.57.4
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
mod rewrite question for canonical issues
mod_rewrite canonical
chazeo




msg:3291049
 4:16 pm on Mar 23, 2007 (gmt 0)

OK, so I need to generate the code to create a 301 redirect from a www version of a website to a non-www version. I found this code which works well for the opposite case (non-www to www). Can alyone help me rewrite this to make the opposite condition true?

code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST}!^www\.domain\.com$
RewriteRule ^(.*)$ [domain.com...] [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.html\ HTTP/
RewriteRule index\.html$ [domain.com...] [R=301,L]
</IfModule>

 

phranque




msg:3291469
 10:01 pm on Mar 23, 2007 (gmt 0)

please refer to jdMorgan's response in this thread for the htaccess url canonicalization library [webmasterworld.com].
after making some minor tweaks to your code, try it and report on your results.

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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved