.htaccess mod_rewrite - 如何从重写规则中排除目录 [英] .htaccess mod_rewrite - how to exclude directory from rewrite rule

查看:37
本文介绍了.htaccess mod_rewrite - 如何从重写规则中排除目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 .htaccess 文件中有 8 行重写规则.我需要从这些规则中排除我服务器上的两个物理目录,以便它们可以访问.现在所有请求都发送到 index.php 文件.

I have 8 lines of rewrite rules in my .htaccess file. I need to exclude two physical directories on my server from these rules, so they can become accessible. For now all requests are sent to index.php file.

要排除的目录:admin"和user".

Directories to exclude: "admin" and "user".

所以 http 请求:http://www.domain.com/admin/ 不应该是传递给 index.php 文件.

So http requests: http://www.domain.com/admin/ should not be passed to index.php file.

ErrorDocument 404 /index.php?mod=error404

Options  FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

RewriteRule ^([^/] )/([^/] ).html$ index.php?lang=$1&mod=$2 [L]
RewriteRule ^([^/] )/$ index.php?lang=$1&mod=home [L]

推荐答案

在您的其他规则之前尝试此规则:

Try this rule before your other rules:

RewriteRule ^(admin|user)($|/) - [L]

这将结束重写过程.

这篇关于.htaccess mod_rewrite - 如何从重写规则中排除目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆