Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to do the following:

I have about 5 URLs which has to be redirected manuall, the rest automatic means:

These ones have to be redirected manually which has to be redirected to which has to be redirected to

The Rest (if none of the above) - no matter if I enter or has to be redirected to

To sum: I want to hardcode two redirects for test1 and test2, because they have to be redirected to somewhere else. The rest if not test1 or test2 have to be redirected to - how to do ???? – codeworxx 2 mins ago edit

I have no clue, where the problem is: I have created a .htaccess file in www root of with the following content:

RewriteEngine on
RewriteRule test1 [R301]
RewriteRule test2 [R301]
RewriteRule (.*)$1 [R=301,L]

But it does not do what I want.

If I enter or I get an Internal Server Error. If I enter it redirects to$1 ?!?!?!?


share|improve this question

1 Answer 1

up vote 0 down vote accepted
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/test1
RewriteRule (.*) [R=301,L]
RewriteCond %{REQUEST_URI} ^/test2
RewriteRule (.*) [R=301,L]
RewriteCond %{REQUEST_URI} !^(test1|test2)
RewriteRule (.*)$1 [R=301]
share|improve this answer
perfect - that worked as expected! thanks :) you saved my day! – codeworxx Aug 20 '11 at 16:12

Your Answer


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.