Forum Moderators: phranque
I had this done for me, since I'm no expert. How can I now change this to redirect the following ...
mydomain.com/directory to newdomain.com/directory
Another possibility I may want to do is to redirect ...
mydomain.com/directory to newdomain.com
All help much appreciated. Thanks.
[edited by: jdMorgan at 2:00 pm (utc) on Nov. 3, 2003]
[edit reason] Delinked [/edit]
Please do not post large blocks of code, or ask us to write your code for you.
It might help if you took a stab at it first, and posted what you came up with.
Here are the pages I read when I was just starting out:
Regular expressions [etext.lib.virginia.edu]
mod_rewrite [httpd.apache.org]
RewriteCond %{HTTP_HOST} mydomain.com$ [NC]
RewriteRule ^(.*) http://www.newdomain.com/newdirectory/$1 [R=301,L]
This seems to be working fine when the URL includes the actual file requested (e.g. mydomain.com/testdir/test.html is redirected to newdomain.com/newdirectory/test.html)
However, when only the directory with no filename is specified I have 2 different problems depending on whether the trailing slash is used.
If the trailing slash is used in the request (e.g. mydomain.com/testdir/), I get a 403 error, even though index.htm exists.
If it is not used (e.g. mydomain.com/testdir), a symbolic link is taken as the destination (e.g. newdomain.com/newdirectory//home/virtual/site20/fst/var/www/html/testdir).
What am I doing wrong? Thanks.
[edited by: jdMorgan at 2:01 pm (utc) on Nov. 3, 2003]
[edit reason] Delinked [/edit]
Redirect 301 /olddirectory [domain.com...]
>If the trailing slash is used in the request (e.g. mydomain.com/testdir/), I get a 403 error, even though index.htm exists.
A server status code of 403 means that access is forbidden. It says nothing about whether the file exists.
> If it is not used (e.g. mydomain.com/testdir), a symbolic link is taken as the destination (e.g. newdomain.com/newdirectory//home/virtual/site20/fst/var/www/html/testdir).
Your mod_rewrite code, as written above, cannot do this.
Adding these two bits of evidence, I suspect you have an incorrect directive -- either in your web root .htaccess, or in the server's httpd.conf file -- that is causing this problem. You may want to ask your host to check httpd.conf, since this misconfiguration will probably cause other problems.
Jim