• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 498
  • Last Modified:

.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"];
...
0
NeoTeq
Asked:
NeoTeq
  • 6
  • 2
1 Solution
 
NeoTeqAuthor Commented:
Note the 'getCleanString' function just cleans up my user/querystring input in the first, older example.
0
 
NeoTeqAuthor Commented:
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".
0
 
NeoTeqAuthor Commented:
Okay, here we go...

The problem is not the rewriterule. I'm not getting anything from the querystring for some odd reason.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Tol_cvCommented:
i'm missing what you need from rewrite   something like (for directory 2) ..
request:       /directory1/<arg1>  redirected to index.php?page=arg1
0
 
NeoTeqAuthor Commented:
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?
0
 
Tol_cvCommented:

if you use something like :

RewriteRule ^/dir2/([^/]*)$ index.php?page=$1 [L] , what't the result?
0
 
NeoTeqAuthor Commented:
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.
0
 
NeoTeqAuthor Commented:
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 ;)
0
 
PashaModCommented:
Closed, 450 points refunded.
PashaMod
Community Support Moderator
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now