2012-04-05 68 views
12

我试图调整我的htacess文件以跳过重写规则,如果文件或目录存在,但是当文件存在时,它将URL更改为不同的内容。我不知道为什么会发生这种情况。这里是我的htaccess文件:如果文件或目录存在,RewriteCond跳过规则

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服务器文件夹中。

感谢您的帮助!

回答

25

删除多余[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] 
相关问题