htaccess无法在子目录中工作

时间:2018-02-02 07:14:40

标签: .htaccess

我的网站托管在子目录(http://example.com/folder)。

在根目录中,我将http://example.com转发到我创建了博客页面的http://example.com/folder,我重写了这样的网址:

RewriteEngine On
RewriteRule ^([^/]*)-(.+)\.html$ \/folder\/blog\.php?title=$1&bid=$2 [L]

这是有效的,但它会影响其他文件夹网址,例如http://example.com/folder2,会被重定向到我的博客。

1 个答案:

答案 0 :(得分:0)

您可以检查目录或文件是否确实存在,并且不应用具有条件的重定向:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)-(.+)\.html$ \/folder\/blog\.php?title=$1&bid=$2 [L]