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

index.php?action=affiliate/registration

/affiliate/registration/

I would like to rewrite this urls to index.php?action=notfound because affiliate/registration substring is found in any part of URL.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I would do something like:

# Don't rewrite if the request is for a real file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)(affiliate|registration)+(.*) index.php?action=notfound [QSA,L]

If there's always a / before, I would rather do:

# Don't rewrite if the request is for a real file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/(affiliate|registration)+(.*) index.php?action=notfound [QSA,L]

If there's always a / after, I would rather do:

# Don't rewrite if the request is for a real file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)(affiliate|registration)+/(.*) index.php?action=notfound [QSA,L]

If there's always a / before and after, I would rather do:

# Don't rewrite if the request is for a real file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/(affiliate|registration)+/(.*) index.php?action=notfound [QSA,L]
share|improve this answer

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.