Forum Moderators: phranque

Message Too Old, No Replies

rewrite domain alias

rewrite alias

         

jimmybeige2

11:01 am on Oct 7, 2009 (gmt 0)

10+ Year Member



Hi,
I have a domain alias for my site http://example.com and the alias is called [example-alias.net....]
I want the alias to point towards http://example.com/samplepage.php. I have used the following code:

RewriteCond %{HTTP_HOST} !^http://(www\.)?example-alias\.net$ [NC]
RewriteRule ^$ /samplepage.php [L]

This is working but it is also causing http://example.com to show http://www.example.com/samplepage.php as well. Is there any way I can stop this. I want http://example.com to stay as it was displaying the regular index.htm page.

Thanks a lot for any help.

[edited by: jdMorgan at 12:54 pm (utc) on Oct. 7, 2009]
[edit reason] exmaple->example [/edit]

Caterham

12:57 pm on Oct 7, 2009 (gmt 0)

10+ Year Member



Your condition has two errors:

It negates the expression "is not expression" and it contains parts which aren't present in a Host request header.

RewriteCond %{HTTP_HOST} ^(www\.)?example-alias\.net [NC]
RewriteRule ^$ /samplepage.php [L]

In the feature one can get rid of mod_rewrite and could use

<If "$req{Host} = '/^(www\.)?example-alias\.net/'">
DirectoryIndex samplepage.php
</If>

jdMorgan

12:58 pm on Oct 7, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is most likely occuring as the result of another rule or Redirect directive in your .htaccess file or server configuration files. Your rule is an internal URL-path-to-filepath rewrite, and does not itself invoke an external redirect, so it cannot be responsible for informing the client that the URL has changed.

Also, from your described requirements, it looks like you should not be negating the RewriteCond pattern with "!".

Jim

jimmybeige2

1:32 pm on Oct 7, 2009 (gmt 0)

10+ Year Member



Great, thanks a lot for that. The rule below worked great!

RewriteCond %{HTTP_HOST} ^(www\.)?example-alias\.net [NC]
RewriteRule ^$ /samplepage.php [L]