views:

527

answers:

2

I am trying to write an htaccess file that essentially does this:

if(requested file == "some-file.php" || requested file == "some-file2.php" || requested file == "some-file3.php")
   then Rewrite to redirector.php?uri=some-file.php <- substitute requested file without passing any parameters
else
// existing rewrite conditions from silverstripe
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]

Is this possible using htaccess?

A: 

I would think all you need to do is place your 3 unique requested files as 3 RewriteRules at the top, above those RewriteCond's:

RewriteEngine On
RewriteRule /(some-file.php) http://test.dev/redirector.php?uri=$1 [L]
RewriteRule /(some-file2.php) http://test.dev/redirector.php?uri=$1 [L]
RewriteRule /(some-file3.php) http://test.dev/redirector.php?uri=$1 [L]

// rest of Rewrite Stuff
meder
A: 

Try this rule:

RewriteRule ^(some-file\.php|some-file2\.php|some-file3\.php)$ redirector.php?uri=$1
Gumbo