繁体   English   中英

需要以某些字符开头的网址的mod_rewrite异常

[英]need mod_rewrite exceptions for urls starting with certain characters

我对mod_rewrite不太了解,但是似乎找不到这个问题的答案。 我正在开发一个简单的应用程序,并通过index.php主页面路由所有url(少数几个除外)。 因此,例如mysite.com/test转到index.php,然后在php中确定该URL是什么并加载适当的页面。

我的问题是,我需要从此规则中排除电子邮件验证或其他将来可能发生的例外情况。 电子邮件验证链接的示例是: http : //myrul.com/php-login-advanced/register.php? id=2&verification_code= .....等

所以...有一种方法可以从某些字符开头的重写规则中排除url。 在这种情况下,“ php-”可以解决问题。

我当前的重写条件是:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|&|register\.php|php|
css|images|javascript|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php?/$1 [L]

尝试使用查询字符串

RewriteCond %{QUERY_STRING}     ^query=(.*)$    [NC]

您可以使用RewriteCond %{REQUEST_URI}排除特定的URI,如下所示:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/php- [NC]
RewriteCond $1 !^(index\.php|register\.php|php|css|images|javascript|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

暂无
暂无

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

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