Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have an htaccess file in my main directory which redirects all top-level directories to a PHP file.

-> /Loch would go to /profile.php?username=Loch

But I also have a subdirectory, lets call it test

I need a rule in test that says, "any sub paths of my directory are actually GET variables.

For example, linking to /test/hello/hi

Should actually go to /test/receiver.php?dataset=hello&action=hi

However, when I use the following rules within an htaccess file in the /test/ directory, it doesn't work this way (I get a 500 error).

RewriteBase /

RewriteEngine On
RewriteRule ^(.*?)/(.*?)/?$ /receiver.php?dataset=$1&action=$2
RewriteRule ^(.*?)/?$ /receiver.php?dataset=$1

I hope I've provided enough info, please help! Thank you.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Your regular expressions are not valid. * and ? are both quantifiers which apply to the previous character, and so *? doesn't make sense. You probably want this:

RewriteRule ^(.+)/(.+)/?$ /receiver.php?dataset=$1&action=$2
RewriteRule ^(.+)/?$ /receiver.php?dataset=$1
share|improve this answer
    
Thank you very much. Would upvote but I don't have enough points! –  iLoch Aug 24 '12 at 9:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.