modRewrite ads a not neccessary ".php" to my URL

New to mod_rewrite? This is a good place to start.

modRewrite ads a not neccessary ".php" to my URL

Postby mard » Sun Jan 08, 2006 7:41 am

Hi,

first of, I'm new to things belonging Apache and ModRewrite especially - didn't need detailed knowledge about it until some weeks ago.

What I wanted to do: All folders beyond a certain level should be treated as GET-Variable. Why? I don't like URLs like
http://www.example.com/doit/index.php?level=admin&name=archer&file=archiv
- it would be nicer to have a URL like
http://www.example.com/doit/admin/archer/archiv

and then letting Apache do the internal rewritings which then are used by my PHP-Script.

OK, I started on it - and it worked. But - not everytime. And now that's the problem:

My folderstructure is like this:

www.example.com/doit/


My htaccess-File is located in /doit/ and contains the following code:

Code: Select all
RewriteEngine on
RewriteRule !^img(.*)$  - [C]
RewriteRule  ^(.*)\/    index.php?param=$1      [L]


So everytime I have a link like "www.example.com/doit/admin/archer/"
my PHP-Script get's a variable $_GET['param'] containing "admin/archer".

Works quite fine ...

... until a URL sounds like "www.example.com/doit/doit/archer/" - having the folder and virtual subfolder both sounding alike ("doit")

In this case my PHP-Script get's a variable $_GET['param'] containing "doit.php/archer"

Now my big question: WHY? Why does RewriteEngine add a ".php" to my "doit" ?

thx in advance..
mard
mard
 
Posts: 1
Joined: Sun Jan 08, 2006 7:10 am

Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 32 guests

cron