I'm fairly new to mod rewrite, so maybe my problem is I just dont know enough, but I think i'v found a really funny error in mod re write, can someone please help? This is also my first post in this forum, so if i'v made any mistakes, please tell me. Sorry that the post is a bit long, but either i'm really stupid or its something pretty interesting, so please carry on reading
I have created a .htaccess file which looks like the following
- Code: Select all
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
#New rules for new mod re-write
rewriterule ^(.*)_type1$ test/index.php?cat1=$1&type=type1 [NC]
rewriterule ^(.*)\/(.*)_type1$ test/index.php?cat1=$1&cat2=$2&type=type1 [NC]
rewriterule ^(.*)\/(.*)\/(.*)_type1$ test/index.php?cat1=$1&cat2=$2&cat3=$3&type=type1 [NC]
I have one script in a "test" directory (which is in htdocs) called index.php
So my file structure looks like blah blah/htdocs/test/index.php
(ps the .htaccess file is in the test folder)
All im trying to do at the moment is check what variables mod rewrite sends to the script, so I only have some var_dumps in the script.
This is what index.php looks like
- Code: Select all
<?php
echo "GET <BR>";
var_dump($_GET);
echo "<br>";
echo "POST <BR>";
var_dump($_POST);
echo "<br>";
?>
So I wanted to test the first rule
So I entered in a URL
(ps my machine name is dev)
http://dev/test/screws_type1
And got the following results
GET
array(2) { ["cat1"]=> string(6) "screws" ["type"]=> string(5) "type1" }
POST
array(0) { }
AWESOME!
Now lets try test the second rule
so i'm going to enter the following URL
http://dev/test/screws/bolts_type1
And this is now the result
GET
array(4) { ["cat1"]=> string(4) "test" ["cat2"]=> string(9) "index.php" ["cat3"]=> string(5) "bolts" ["type"]=> string(5) "type1" }
POST
array(0) { }
Firstly problem, I dont understand how its calling the third rule (I know this because there are 4 variables passed to the page). I mean, the .htaccess is in the test folder, so it shouldn't have taken the test directory as the first argument, right? I mean the first rule doenst count the test directory.
Second problem, the second variable passed has a value of "index.php" (the script name). Little bit strange!
Can anyone help me?
Many many thanks in advance