加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

正则表达式 – 如果文件或目录存在,则RewriteCond跳过规则

发布时间:2020-12-14 06:31:28 所属栏目:百科 来源:网络整理
导读:我试图调整我的htacess文件以跳过重写规则,如果文件或目录存在,但当文件存在时,它会将URL更改为不同的.我不知道为什么会这样.这是我的htaccess文件: RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-f [OR]RewriteCond %{REQUEST_FILENAME} !-dRewriteR
我试图调整我的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]

目录/ project / nti存在,带有index.php文件.输入地址mywebsite.com/folder/project/nti后,它将更改为mywebsite.com/folder/project/nti/?view=projectu0026amp;project=nti.我将此应用于示例站点位于子文件夹中的测试服务器上,但实现后,它将位于根Web服务器文件夹中.

谢谢你的帮助!

删除额外的[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]

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读