NeoTeq
asked on
.htaccess rewriterules???
I'm having a particularly lousy morning right now, because of something I can't explain. On my testserver, I have two directories. In the first directory, the rewriterule works, in the second it doesn't. Any ideas why?
=== dir1
= .htaccess
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)[/]?$ index.php?group=$1&page=$2 [L]
= index.php
...
$MenuGroupID = (isset($_GET["group"]) ? getCleanString($_GET["grou p"]) : 1);
$PageID = (isset($_GET["page"]) ? getCleanString($_GET["page "]) : 1);
...
=== dir2
= .htaccess
RewriteEngine On
RewriteRule ^([^/]*)[/]?$ index.php?page=$1 [L]
= index.php
...
echo $_GET["page"];
...
=== dir1
= .htaccess
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)[/]?$ index.php?group=$1&page=$2
= index.php
...
$MenuGroupID = (isset($_GET["group"]) ? getCleanString($_GET["grou
$PageID = (isset($_GET["page"]) ? getCleanString($_GET["page
...
=== dir2
= .htaccess
RewriteEngine On
RewriteRule ^([^/]*)[/]?$ index.php?page=$1 [L]
= index.php
...
echo $_GET["page"];
...
ASKER
Note 2 (I hate it when I forget things), the second example prints "index.php" when I go to http://testserver/dir2/test/ while i want it to return "test".
ASKER
Okay, here we go...
The problem is not the rewriterule. I'm not getting anything from the querystring for some odd reason.
The problem is not the rewriterule. I'm not getting anything from the querystring for some odd reason.
i'm missing what you need from rewrite something like (for directory 2) ..
request: /directory1/<arg1> redirected to index.php?page=arg1
request: /directory1/<arg1> redirected to index.php?page=arg1
ASKER
My last comment was wrong, please ignore it.
I'm not sure what you're missing... The redirect as you describe it, is what I want?
I'm not sure what you're missing... The redirect as you describe it, is what I want?
if you use something like :
RewriteRule ^/dir2/([^/]*)$ index.php?page=$1 [L] , what't the result?
ASKER
The problem is that the .htaccess is in /dir2/ and eventually it will be in website's root dir when I put it online. So that will not work.
ASKER
I feel silly...
Imagine somebody going to:
- http://someserver/articles/
Which gets redirected to:
- http://someserver/index.php?page=articles
Which again (since it matches the regex) gets redirected:
- http://someserver/index.php?page=index.php?page=articles
Nice recursion there ;)
Imagine somebody going to:
- http://someserver/articles/
Which gets redirected to:
- http://someserver/index.php?page=articles
Which again (since it matches the regex) gets redirected:
- http://someserver/index.php?page=index.php?page=articles
Nice recursion there ;)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER