Dreamhost + redirect problems


#1

I have been having problems setting up a good .htaccess redirect since moving from windows server to dreamhost.

I have .com and .co.uk and would like to .co.uk to 301 redirect to the .com

I think all the control panel directs are 302

the .co.uk is currently on a control panel point to the .com

Anyone got a better way???

Also had to change all my old pages over to .phtml

So need to 301 redirect all .html and .asp to new extension of .phtml.

This didnt work

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

(Redirection for this url exceeded)
is the error message

This one does work

RedirectMatch 301 (.).html$ http://www.mypage.com$1.phtml
RedirectMatch 301 (.
).asp$ http://www.mypage.com$1.phtml

It covers the html, asp to phtml thing

BUT it doesnt allow any http://www.mypage.com

it converts to http://www.mypage.com/index.phtml

so this means EVERYTHING even http://www.mypage.com gets 301.

(I think this is not so good for my root and for all prior google links (why is www.mypage.com treated different that www.mypage.com/index.phtml ?)

#--------
Does anyone have a script that sends all 404 errors through a redirect to http://www.mypage.com

Errordocument 404 http://www.mypage.com used to work but not since I set up a database as it did something to the php and cgi not sure what?

It would be best to allow http://www.mypage.com to stay as it is (no automatic change to mypage.com/index.phtml) and does the .html & .asp transfer to corresponding pages in .phtml

#--------
With all these functions covered it would be perfect!

Hoping for help!

www.martialarm.com
The New Way To Train!


#2

[quote]RewriteEngine ON
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L][/quote]
Of course you get a redirect limit exceeded, you’ve just sent a redirect to the very same URL, creating a simple loop.

You forgot to actually convert the extension from one to another there. How come you didn’t copy what you did for RedirectMatch?

RewriteEngine on RewriteRule ^(.*)\.html$ http://example.com/$1.phtml [R=301,L] RewriteRule ^(.*)\.asp$ http://example.com/$1.phtml [R=301,L]
Or better yet just use a single rule…

RewriteEngine on RewriteRule ^(.*)\.(html|asp)$ http://example.com/$1.phtml [R=301,L]
I don’t see any problems with it when trying to browse to http://example.com/

As for doing an external redirect for 404s - not a good idea but don’t know why it wouldn’t work.

PS. Don’t crosspost, people will see your message no matter where it is because of the “show new messages in past day” function.

:cool: Perl / MySQL / HTML CSS