Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite

Newbie - Help needed Please

         

BradEdward

9:31 am on Jul 29, 2005 (gmt 0)



Hi there,

I am new to this forum and also to the area where I hope someone can help me out. I am trying ro redirect requests for a few domain names to different files using mod-rewrite but am coming unstuck. I do know that mod-rewrite is enabled for my use.

I am trying to redirect as follows:

www.example.co.za must redirect to www.example.co.uk/about.php

and..

www.example.co.za must redirect to www.example.co.uk/about.php

The code I have inserted in my .htaccess file is as follows which is causing the webserver to say I have not uploaded an index file at www.example.co.uk:

-----------------------------------------------

RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www\.)?example\.co.za
RewriteRule .* http://www.example.co.uk/about.php [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?example\.co.za
RewriteRule .* http://www.example.co.uk/about.php [R=301,L]

-----------------------------------------------

If anyone in the know can assist, i'd really be greatful.

Brad

[edited by: jdMorgan at 3:30 pm (utc) on July 29, 2005]
[edit reason] Obscured specifics per TOS. [/edit]

jdMorgan

3:31 pm on Jul 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Brad,

Welcome to WebmasterWorld!

Your code looks fine, which means it should work *if* it is executed for requests for your .za domains. So, that is one problem: You need to make sure that those domains resolve to the directory where this code is installed.

You say that you know that mod_rewrite is installed, but do you know if it works? A simple test is to place a rule like:


RewriteRule ^silly\.html$ /index.php [L]

in your .uk site's root directory .htaccess file. Then request /silly.html from your .uk site. If the rule works, then you will see the page contents created by the index.php 'file'. If not, you will probably see a 404-Not Found error. This simple test is agood thing to do before getting into more complex applications.

If it does not work, check your server error log; It will often tell you exactly what's wrong.

Jim