开发者

Various htaccess redirect methods and why?

I have an obsolete url (mydomain.com/page.html) which naturally returns a 404 error. I want to implement a permanent 301 redirect back to my home page at mydomain.com. (Apache/Linux server with permission to manually edit htaccess file)

I want to be co开发者_运维问答mpliant with Google's requirement to have old pages redirected with a 301.

Three methods work but which one is the best and why? Pros & cons, if any?

1- This is what cPanel writes automatically (seems like overkill)...

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.com$
RewriteRule ^page\.html$ "http\:\/\/www\.mydomain\.com" [R=301,L]

2- This is what I've used in the past...

Redirect permanent /page.html http://www.mydomain.com

3- I'm wondering if this is best...

Redirect 301 /page.html http://www.mydomain.com

Thank-you for your opinions!


Solution #1 uses mod_rewrite and will be slower. There is no difference between #2 and #3 - both use mod_alias and should be faster than #1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜