简体   繁体   English

htaccess RewriteRule问题

[英]htaccess RewriteRule issue

I am new to .htaccess and I have found a few articles and I've tried to make it work, but keep failing. 我是.htaccess的新手,我找到了几篇文章,并尝试使其正常运行,但一直失败。

I have the following in my .htaccess file:- 我的.htaccess文件中包含以下内容:-

<IfModule mod_ssl.c>
    RewriteBase /mydomain.com/
</IfModule>
<IfModule !mod_ssl.c>
    RewriteBase /
</IfModule>
RewriteEngine On
RewriteRule ^([^.]*)$ index.cgi/$1 [L]

However, I want to be able to go to mydomain.com/more-info , but this rule is making it mydomain.com/index.cgi/more-info 但是,我希望能够转到mydomain.com/more-info ,但是此规则使它成为mydomain.com/index.cgi/more-info

How can I make is so that "more-info" is exempt from this rule? 我如何才能使“更多信息”不受此规则约束?

Thank you in advance. 先感谢您。


So, Ulrich suggested the following... 因此,乌尔里希提出了以下建议...

#if not /more-info
RewriteCond %{REQUEST_URI} !^/more-info$ [NC]
RewriteRule ^([^.]*)$ index.cgi/$1 [L]

...but I still get '404 Not Found'. ...但是我仍然得到“ 404 Not Found”。 The more-info directory contains index.htm, and if I turn this RewriteEngine off, it works fine. more-info目录包含index.htm,如果我关闭此RewriteEngine,它将正常工作。

Add a RewriteCond Directive before 在之前添加RewriteCond指令

RewriteRule ^([^.]*)$ index.cgi/$1 [L]

that exempts /more-info. 可以免除/ more-info。 Something like - 就像是 -

RewriteCond %{QUERY_STRING} != /more-info

You may find some examples here -> http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond 您可以在此处找到一些示例-> http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond

As below 如下

#if not /more-info
RewriteCond %{REQUEST_URI} !^/more-info$ [NC]
RewriteRule ^([^.]*)$ index.cgi/$1 [L]

您可以尝试以下规则:

RewriteRule ^((?!more-info)[^.]*)$ index.cgi/$1 [L,NC]

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

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