Forum Moderators: phranque

Message Too Old, No Replies

301 Redirecting a DIR to a .html File

301 .htaccess question

         

Voom

6:47 pm on Dec 18, 2007 (gmt 0)

10+ Year Member



I'm attempting to 301 a directory on an old domain to a .html file on a new domain...

I tried the following in my .htaccess file, and it did not work:

redirect 301 /olddir/ [newdomain.com...]

Any suggestions?

jdMorgan

7:29 pm on Dec 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That would redirect /olddir/something to http://www.example.com/newfile.html/something

You need to use RedirectMatch to explicitly tell mod_alias [httpd.apache.org] to drop the trailing path info:


RedirectMatch 301 ^/olddir/(.*)$ http://www.example.com/newfile.html

Jim

Voom

7:44 pm on Dec 18, 2007 (gmt 0)

10+ Year Member



Jim,

That worked great! Thank you so much! You are the man...

On thing though... I had to take this line of code out for it to work:

RewriteRule ^(.*)$ http://www.example.com$1 [R=301,L]

How can I still redirect a request to the main old domain to the new main domain without having that cancel out the sub domain requests?

[edited by: jdMorgan at 8:32 pm (utc) on Dec. 18, 2007]
[edit reason] example.com [/edit]

jdMorgan

8:08 pm on Dec 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm sorry, please back up a bit and tell me what each of the two directives is intended to do. Your new rule apparently redirects all requests to newdomain, but as shown, might well result in a loop. I see nothing having to do with subdomains...

Jim

[edited by: jdMorgan at 8:32 pm (utc) on Dec. 18, 2007]