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
2009-10-21 09:12:54
No luck I'm afraid (doesn't seem to redirect at all). Thanks anyway.
BrynJ
2009-10-21 09:59:24
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
2009-10-21 10:03:16
.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
2009-10-21 10:11:17
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
2009-10-21 10:23:41
+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
2009-10-21 10:43:12