Link to home
Start Free TrialLog in
Avatar of NeoTeq
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["group"]) : 1);
$PageID = (isset($_GET["page"]) ? getCleanString($_GET["page"]) : 1);
...


=== dir2
= .htaccess
RewriteEngine On
RewriteRule ^([^/]*)[/]?$ index.php?page=$1 [L]

= index.php
...
echo $_GET["page"];
...
Avatar of NeoTeq
NeoTeq

ASKER

Note the 'getCleanString' function just cleans up my user/querystring input in the first, older example.
Avatar of NeoTeq

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".
Avatar of NeoTeq

ASKER

Okay, here we go...

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
Avatar of NeoTeq

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?

if you use something like :

RewriteRule ^/dir2/([^/]*)$ index.php?page=$1 [L] , what't the result?
Avatar of NeoTeq

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.
Avatar of NeoTeq

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 ;)
ASKER CERTIFIED SOLUTION
Avatar of PashaMod
PashaMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial