htaccess RewriteRule issue

144 views Asked by At

I am new to .htaccess and I have found a few articles and I've tried to make it work, but keep failing.

I have the following in my .htaccess file:-

<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

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'. The more-info directory contains index.htm, and if I turn this RewriteEngine off, it works fine.

3

There are 3 answers

0
anubhava On BEST ANSWER

You can try this rule:

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

Add a RewriteCond Directive before

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

that exempts /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

1
Ulrich Palha On

As below

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