Welcome to WebmasterWorld Guest from 54.159.44.227

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

redirect .org and .com to same site

best to use mod_rewrite or simple redirect

     

amznVibe

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

WebmasterWorld Senior Member 10+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



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

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

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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
 

Featured Threads

Hot Threads This Week

Hot Threads This Month