2013-07-27 24 views
0

我需要重写那些在http://onlifestyle.org/(DIRECTORY)/catogory/post的形式显示在的http://onlifestyle.org/catogory/post形式的浏览器,但仍打在http://onlifestyle.org/(DIRECTORY)/catogory/post 感谢如何重写链路子directoru的.htaccess

+0

看看类似[像这样一个](http://stackoverflow.com/questions/990392/htaccess-rewrite-to-redirect-root-url-to-subdirectory),[我的答案在这里](http ://stackoverflow.com/questions/17158767/url-rewriting-with-htacess/17751227#17751227)或谷歌如何使花式网址使用htaccess。您将丑陋的网址重定向到花哨的网址,并且您在内部将该花哨的网址重写为丑陋的网址。您必须确保重定向与内部重写的url不匹配,方法是在重写时使用END标志,或者使其与其他方式不匹配。 – Sumurai8

回答

1
资源的所有链接

内部重定向http://onlifestyle.org/catogory/posthttp://onlifestyle.org/directory/catogory/post

RewriteRule ^category/post/?$ /directory/category/post [L] 

您的网址更改从http://onlifestyle.org/directory/catogory/posthttp://onlifestyle.org/catogory/post

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+directory/category/post/? [NC] 
RewriteRule^/category/post [R=302,L] 

如果一切正常,如果您愿意,则将302更改为301。