mod_rewrite:忽略/目录/在url中

时间:2014-12-15 15:05:06

标签: .htaccess mod-rewrite

更好的网址结构我想拥有mysite.com/downloads/file.pdf即使文件位于mysite.com/assets/downloads/file.pdf

如何链接到mysite.com/downloads/file.pdf但是使用mod_rewrite运行mysite.com/assets/downloads/file.pdf

1 个答案:

答案 0 :(得分:0)

您可以在DOCUMENT_ROOT/.htaccess文件中使用此代码:

RewriteEngine On
RewriteBase /

RewriteRule ^(downloads/.+)/?$ assets/$1 [L,NC]