htaccess的mod_rewrite的 - 如何排除重写规则目录 [英] .htaccess mod_rewrite - how to exclude directory from rewrite rule
本文介绍了htaccess的mod_rewrite的 - 如何排除重写规则目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的.htaccess文件8行重写规则。我需要排除这些规则我的服务器上的两个物理目录,这样他们就可以成为访问。现在所有的请求都被发送到index.php文件。
目录排除:admin和用户。
所以HTTP请求: http://www.domain.com/admin/ 不应该被传递到index.php文件。
的ErrorDocument 404 /index.php?mod=error404
有FollowSymLinks
RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{HTTP_HOST}!^ WWW \。域\ .COM $ [NC]
重写规则^(。*)$ http://www.domain.com/$1 [R = 301,L]
。重写规则^([^ /])/([^ /])\ HTML $的index.php 1 LANG = $&放大器; MOD = $ 2 [L]
重写规则^([^ /])/ $的index.php 1 LANG = $&放大器;mod=家[L]
解决方案
你的其他规则之前尝试这条规则:
重写规则^(管理员|用户)($ | /) - [L]
这将结束重写的过程。
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.
Directories to exclude: "admin" and "user".
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]
This will end the rewriting process.
这篇关于htaccess的mod_rewrite的 - 如何排除重写规则目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文