Click to See Complete Forum and Search --> : strange RewriteRule behavior


Drakim
10-02-2008, 10:30 AM
RewriteCond %{HTTP_HOST} ^blog.drakim\.net$ [NC] //check that we are on the blog.drakim domain.
RewriteCond %{QUERY_STRING} !^.+$ //check that there are no GET values in the url
RewriteRule ^(j.+)$ /index.php?GET=$1 [L] //if there was no GET value, go to index.php again, and put the requested file in a GET value


This works perfectly.

If I use the adress "blog.drakim.net/javascript", it will redirect perfectly back to the index.php, with the "javascript" string in the GET value.

However, this will only work if the keyword here starts with j

Easy as pie, we will just remove that j, right?

RewriteCond %{HTTP_HOST} ^blog.drakim\.net$ [NC]
RewriteCond %{QUERY_STRING} !^.+$
RewriteRule ^(.+)$ /index.php?GET=$1 [L]

This, however, throws great balls of error signs. This one to be more specific:

Forbidden

You don't have permission to access /site-cgi-bin/php-cgiwrap/kim/index.php on this server.

It works if I set an absolute path, but that's not what I'm trying to do here. Why is the starting directory changed? I don't understand.

Drakim
10-02-2008, 10:38 AM
okay, after some testing, I realized it's some kind of loop.

changing the required letter from "j" to "i" makes the forbidden problem come up again, most likely because "index.php" starts with i, thus producing the same loop as a wild character.

It's strange though, the GET check should see to that that doesn't happen. Anybody know why not?

opifex
10-02-2008, 02:33 PM
what is it you need to do?
have you closed the blog sub-domain and need to redirect?
have you moved the blog?
do you only want to redirect certain parts of the blog??

the method really depends on the situation.....

Drakim
10-02-2008, 03:08 PM
I'm trying to make the url more pretty.

So, when you are at the subdomain blog, and when you have anything after the base url, like this:
blog.drakim.net/javascript

Then it should rewrite to this:
blog.drakim.net?GET=javascript