homepage Welcome to WebmasterWorld Guest from 54.166.110.222
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
redirect .org and .com to same site
best to use mod_rewrite or simple redirect
amznVibe




msg:1497159
 6:36 am on Sep 25, 2003 (gmt 0)

I am helping a non-profit straighten out their website.
I noticed some people were trying to use the .com version
of their .org domain name so I helped them get the .com registered.

Now I have to ponder the best way to map the .com to the .org
I don't want to leave the .com on their screen but taken them to the requested page instead on the .org

I am assuming redirectmatch is not the best approach to this.
Fortunately they are on an apache server, also with mod_rewrite.

Can anyone help me figure out the correct rewrite rule for even the most complex urls?

Thanks for any help!

 

amznVibe




msg:1497160
 6:39 am on Sep 25, 2003 (gmt 0)

Doh, a few more minutes of digging and I found the same question w/answer.

[webmasterworld.com...]

However I am having trouble getting either way to work and getting a 500 error.

Might this be a character/space issue with the board?

Which way is better and how can I modify to allow them to leave out www?

RewriteEngine on
RewriteCond %{HTTP_HOST}!^www.mydotorg.org
RewriteRule ^.*$ [mydotorg.org%{REQUEST_URI}...] [L]

RewriteEngine On
RewriteCond %{HTTP_HOST}!^www.my-domain.org$
RewriteRule ^(.*)$ [my-domain.org...] [L,R=permanent]

jdMorgan




msg:1497161
 1:22 pm on Sep 25, 2003 (gmt 0)

amznVibe,

There needs to be a space before the exclamation point in the first RewriteCond. This space is removed by posting on the board. You can get one to stay in your post if you type in two spaces.

The Options directive may be required if it is not already the default setting in your server configuration. However, on some server set-ups, the Options directive itself can cause a 500-Server Error.

Do not include a "$" end-anchor on the domain name pattern in the first RewriteCond. This can cause failures if anything (such as a port number) is appended.

This code will redirect all requests to domains other than www.mydomain.org back to www.mydomain.org, including a redirect for .com, .net, or any other TLD, and also for upper-case variants of .org.

All literal periods in the regular-expressions patterns need to be escaped by preceding them with a slash. Do not escape characters in the substitution (destination URL) string.

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.my-domain\.org
RewriteRule ^(.*)$ http://www.my-domain.org/$1 [L,R=permanent]

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