Reputation: 14250
I have a rewrite statement in my .htaccess like below. Is it possible to make it less line or fewer statement?
RewriteEngine On
RewriteCond %{REQUEST_URI} /file1.asp
RewriteRule ^.*$ /project/test.php?file=1 [R=302]
RewriteCond %{REQUEST_URI} /customer.form
RewriteRule ^.*$ /project/test.php?form=true [R=302]
RewriteCond %{REQUEST_URI} /clear
RewriteRule ^.*$ /project/test.php?clear=1 [R=302]
RewriteCond %{REQUEST_URI} /redirect
RewriteRule ^.*$ /project/test.php?url=play [R=302
]
I feel like the above statement could be reduce. Is it possible? Thanks a lot!
Upvotes: 1
Views: 31
Reputation: 784918
Yes you can use a single rule like this using regex alternation:
RewriteEngine On
RewriteRule (file1\.asp|customer\.form|clear|redirect) /project/test.php [R=302,L,NC]
This replaces all of your 4 rules.
Upvotes: 1