使用URL重写,我想要这样:www.xxx.com/view-item/abc到:www.xxx.com/item/abc.pdf。如何在.htaccess中使用重写规则?一直在浏览http://httpd.apache.org/docs/current/rewrite/flags.html#flag_t和其他网站,但无法弄清楚。
如果您希望重写是内部的而没有HTTP 301或302,请尝试以下操作:
RewriteEngine on
RewriteRule ^/view-item/(.+) /item/$1.pdf [L]
如果HTTP 301或302重定向正常,则Mod_rewrite有点过大。您还可以使用RedirectMatch:
RedirectMatch ^/view-item/(.+) /item/$1.pdf
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句