如果的RewriteCond文件或目录是否存在跳过规则(RewriteCond to skip ru

2019-06-23 10:37发布

我想调整我htacess文件跳过重写规则,如果该文件或目录存在,但是当该文件存在,它改变了URL,以不同的东西。 我不知道为什么会这样。 这里是我的htaccess的文件:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^project/([^/\.]+)/?$ index.php?view=project&project=$1 [L]
RewriteRule ^for/content/ag index.php?view=opening&section=ag [L]
RewriteRule ^for/content/bus index.php?view=opening&section=bus [L]
RewriteRule ^for/content/fcs index.php?view=opening&section=fcs [L]
RewriteRule ^for/content/market index.php?view=opening&section=market [L]
RewriteRule ^for/content/trade index.php?view=opening&section=trade [L]
RewriteRule ^for/content/teched index.php?view=opening&section=teched [L]
RewriteRule ^for/content/([^/\.]+)/?$ index.php?view=content_area&section=$1 [L]

目录/项目/ NTI存在,与index.php文件。 当输入的地址mywebsite.com/folder/project/nti,它改变mywebsite.com/folder/project/nti/?view=project&project=nti。 我是一个测试服务器,其中示例站点是一个子文件夹上应用此,但是实施时,它会在根Web服务器文件夹。

谢谢你的帮助!

Answer 1:

删除多余的[OR]有你这样的代码:

# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
# If the request is not for a valid link
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^project/([^/.]+)/?$ index.php?view=project&project=$1 [L,NC,QSA]


文章来源: RewriteCond to skip rule if file or directory exists