简体   繁体   English

如何使用rewirecond从htaccess文件的重写规则中排除特殊页面?

[英]how to use rewirecond for exclusion a special page from rewrite rule in htaccess file?

I use the below rule in my MVC project for redirecting everything to my index.php : 我在MVC项目中使用以下规则将所有内容重定向到index.php

RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

But I want to exclude some pages from this rule, how can I do this? 但是我想从此规则中排除一些页面,我该怎么做?

For example I don't want the below page to redirect: 例如,我不希望下面的页面重定向:

http://www.my_domian/public/checkeditor/kcfinder/browse.php?opener=ckeditor&type=images&CKEditor=des&CKEditorFuncNum=1&langCode=fa

You can add a negative condition before this RewriteRule : 您可以在此RewriteRule之前添加否定条件:

DirectoryIndex index.php
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} !/public/checkeditor/kcfinder/browse\.php\?opener=ckeditor&type=images&CKEditor=des&CKEditorFuncNum=1&langCode=fa [NC]
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

Also I have added 2 conditions to avoid routing for real files and directories. 另外,我还添加了2个条件,以避免路由实际文件和目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM