mod_rewrite problem
am 04.09.2007 07:17:03 von Seth Fischer
I would like to rewrite this:
http://www.domain.name/first/second/third?name=value
To this:
http://www.domain.name/index.php/first/second/third?name=val ue
I am inserting "index.php/" after the domain name.
But I don't want to rewrite the URLs for
a) Files with extension css|gif|jpg|js + others
b) URLs starting with "http://www.domain.name/fourms/"
c) URLs starting with "http://www.domain.name/wiki/"
I am then using php to grab data form the URL ($first=first,
$second=second)
Mod_Rewrite is new to me. From reading the Apache manual I can see it
can be done but
just can't work it out!
Here's what I' trying:
RewriteEngine on
RewriteCond %{REQUEST_URI] !^/forms
RewriteCond %{REQUEST_URI] !^/wiki
RewriteCond %{REQUEST_URI] !\.(gif|jpg|css|js|php|pdf|xml|txt)$
RewriteRule ^(.*)$ index/%1
And the error from the log:
Request exceeded the limit of 10 internal redirects due to probable
configuration error. Use 'LimitInternalRecursion' to increase the
limit if
necessary. Use 'LogLevel debug' to get a backtrace
Thanks for any help
Seth
Re: mod_rewrite problem
am 04.09.2007 17:28:18 von Jim Hayter
seth7f@gmail.com wrote:
> I would like to rewrite this:
>
> http://www.domain.name/first/second/third?name=value
>
> To this:
>
> http://www.domain.name/index.php/first/second/third?name=val ue
>
> I am inserting "index.php/" after the domain name.
>
> But I don't want to rewrite the URLs for
>
> a) Files with extension css|gif|jpg|js + others
> b) URLs starting with "http://www.domain.name/fourms/"
> c) URLs starting with "http://www.domain.name/wiki/"
>
> I am then using php to grab data form the URL ($first=first,
> $second=second)
>
> Mod_Rewrite is new to me. From reading the Apache manual I can see it
> can be done but
> just can't work it out!
>
> Here's what I' trying:
>
> RewriteEngine on
> RewriteCond %{REQUEST_URI] !^/forms
> RewriteCond %{REQUEST_URI] !^/wiki
> RewriteCond %{REQUEST_URI] !\.(gif|jpg|css|js|php|pdf|xml|txt)$
> RewriteRule ^(.*)$ index/%1
>
> And the error from the log:
>
> Request exceeded the limit of 10 internal redirects due to probable
> configuration error. Use 'LimitInternalRecursion' to increase the
> limit if
> necessary. Use 'LogLevel debug' to get a backtrace
>
> Thanks for any help
>
You also need to exempt URLs that already have "index" in place. That
is where you are looping.
Jim
Re: mod_rewrite problem
am 13.09.2007 08:19:05 von sean dreilinger
seth7f@gmail.com wrote:
> I would like to rewrite this:
> http://www.domain.name/first/second/third?name=value
> To this:
> http://www.domain.name/index.php/first/second/third?name=val ue
....
>
> RewriteEngine on
> RewriteCond %{REQUEST_URI] !^/forms
> RewriteCond %{REQUEST_URI] !^/wiki
> RewriteCond %{REQUEST_URI] !\.(gif|jpg|css|js|php|pdf|xml|txt)$
> RewriteRule ^(.*)$ index/%1
try
1. adding a condition to exclude urls that already start with /index (per jim
hayter)
2. did you mean to exclude /forms or /forums, or both?
3. changing %1 to $1 in your substitution string.
4. use qsappend in the RewriteRule to retain any query string
it could look like this, untested:
RewriteEngine on
RewriteCond %{REQUEST_URI] !^/(foru?ms|wiki|index)
RewriteCond %{REQUEST_URI] !\.(gif|jpg|css|js|php|pdf|xml|txt)$
RewriteRule ^/(.*) /index/$1 [last,qsappend]
hth
-sean
--
sean dreilinger - http://durak.org/sean/