【发布时间】:2016-02-24 10:23:34
【问题描述】:
所以我正在研究但还没有解决的问题!
例如网址是http://someurl.com/brands/brand 我想要完成的是 htaccess 让 te 请求转到 url:http://someurl.com/brands/brand 但从 url 中删除“品牌”部分。
另外,如果 url:http://someurl.com/brands 被称为页面“品牌”,则需要显示。所以只有在 /brands/ 后面有品牌时才需要做一个 URL 重写为http://someurl.com/brand
我已经尝试过了,但这篇文章会重定向到不存在的新位置。
RewriteRule ^onze-merken/(.*)$ /$1 [L,R=301]
所以我需要上面没有重定向,它只需要重写 URL。 任何帮助将不胜感激,谢谢!
现在这是我完成重写的 htaccess 部分!
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /onze-merken/(\S+)\s [NC]
RewriteRule ^ /%1 [R=302,L,NE]
# Only rewrite if the directory doesn't exist.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# internal forward from pretty URL to actual one
RewriteRule ^((?!onze-merken/).+)$ /onze-merken/$1 [L,NC]
RewriteRule ^(.*)\.html$ /$1 [L,R=301]
RewriteRule ^(uploads/([a-z0-9_\-\.]+)/__images/custom/(.*)/)(.*)$ http://someurl.com/uploads/$2/__images/custom/$3/$4 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
【问题讨论】:
标签: .htaccess mod-rewrite url-rewriting rewrite