views:

138

answers:

2

I need to redirect all page requests (php, if that matters) on a specific domain to a specific page (again, php) on that domain. I'm looking for a .htaccess, mod_rewrite solution for easy of implementation.

+1  A: 

Something like this might do the trick:

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php/$0 [PT,L]
Alex Sexton
No luck I'm afraid (doesn't seem to redirect at all). Thanks anyway.
BrynJ
You'll have to make sure you are allowing .htaccess rules to be run in your httpd.conf file - as well as make sure you have mod_rewrite installed. This .htaccess piece is straight out of the kohana php framework and works for a ton of people, so it's probably somewhere else in your settings.
Alex Sexton
.htaccess rules and mod_rewrite definitely available - just a question on the above: is this to match existing pages, or pages that don't exist? (My pages exist, I just want the request redirected temporarily).
BrynJ
Ah yes, I am specifically saying that if a page _actually_ exists, then go to it, otherwise do the redirect. In that case, remove those first two Conditions, and you should be alright.
Alex Sexton
+2  A: 

Try this rule:

RewriteCond $1 !=index.php
RewriteRule .+\.php$ index.php [L]

That will redirect all requests that’s URL path ends in .php to the index.php in the same directory as the .htaccess file.

Gumbo