【发布时间】:2016-10-03 18:56:07
【问题描述】:
我使用 RewriteRule 将链接从 ?s=xxx 缩短到 /xxx - 但是我遇到了一些问题,我无法访问某些文件夹中的文件。为了帮助解决这个问题,我在规则中做了一个例外:
RewriteRule ^(inv.*) $1 [L]
这是因为我在“inv”文件夹中有 .pdf 文件。
但问题是我也有一些称为 /invitation 的网站。问题是这个链接给出了 404 错误。
如果我删除上面的行,/invitation 有效 - 但随后我在 /inv/xx.pdf 上收到 404 错误。
如何更改使两者都有效的 RewriteRule。
谢谢。
这是我的整个 .htaccess 文件:
DirectoryIndex i.php index.php index.html
RewriteEngine On
RewriteRule ^robots.txt - [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule ^(inv.*) $1 [L]
RewriteRule ^([^/]+)/?$ /?s=$1 [NC,L]
RewriteRule ^(nyhet)/([^/]+)/?$ /?s=$1&n=$2 [NC,L]
RewriteRule ^([^/]+)/([^/]+)/?$ /?s=$1_$2 [NC,L]
ErrorDocument 404 http://www.domain.com/404
ErrorDocument 403 http://www.domain.com/404
【问题讨论】:
标签: .htaccess mod-rewrite