Redirect 301 - why is my old url being appended to my new url causing a 404 error?

南楼画角 提交于 2020-01-15 09:10:14

问题


Redirect 301 /features/blahblah.php http://www.mysite.com/articles/blahblah1.php

results in http://www.mysite.com/articles/blahblah1.php?q=features/blahblah.php which is a 404 error page not found.

So what am i doing wrong here


回答1:


http://httpd.apache.org/docs/2.0/mod/mod_alias.html#redirect documents exactly what's happening.

You probably want to use RedirectMatch, something like:

RedirectMatch ^/features/blahblah.php http://www.mysite.com/articles/blahblah1.php

If you want it to be a "permanent" redirect with HTTP status 301 (which can be desirable for SEO purposes) rather than a temporary 302 redirect, then instead use:

RedirectMatch permanent ^/features/blahblah.php http://www.mysite.com/articles/blahblah1.php


来源:https://stackoverflow.com/questions/5623225/redirect-301-why-is-my-old-url-being-appended-to-my-new-url-causing-a-404-erro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!