简体   繁体   English

301将资料夹重新导向至上层资料夹

[英]301 Redirect of folder to parent folder

I need to redirect /portfolio/year/ to /portfolio/. 我需要将/ portfolio / year /重定向到/ portfolio /。

The issue with the 301 I have written currently (redirect 301 /portfolio/year http://example.com/portfolio/ ) is that it redirects when someone attempts to access /portfolio/year/2000 or any of the other pages inside /year/. 我目前写的301问题(重定向301 / portfolio / year http://example.com/portfolio/ )是,当有人尝试访问/ portfolio / year / 2000或/中的任何其他页面时,它会重定向年/。

Is there a way I can do this redirect? 有什么方法可以执行此重定向? I need to keep bots and people from accessing the blank /portfolio/year/ page without breaking the rest of the internal pages. 我需要防止漫游器和人员访问空白的/ portfolio / year /页面,而又不要破坏其余的内部页面。

You don't have to use PHP for this. 您不必为此使用PHP。 Just replace your old RewriteRule with this one: RewriteRule ^portfolio/year/?$ portfolio [R=301] The $ at the end of the url makes sure that there are no more characters after portfolio/year/ or portfolio/year 只需用以下内容替换旧的RewriteRule: RewriteRule ^portfolio/year/?$ portfolio [R=301] URL末尾的$可确保在portfolio/year/portfolio/year之后没有更多字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM