Welcome to WebmasterWorld Guest from 188.8.131.52 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
php to html redirect problem uggur msg:4186357 6:49 am on Aug 13, 2010 (gmt 0) Hi, I wanna to rewrite all .php extension to .html I added that code to my htaccess but when i try to html google verification file directly (www.domain.com/googleabcxyz.html), i see 404 page. How can i fix it? # url rewriting php to html RewriteRule ^([0-9a-zA-Z-]+).html$ $1.php RewriteRule ^([0-9a-zA-Z-]+)/([0-9a-zA-Z-]+).html$ $1/$2.php RewriteRule ^([0-9a-zA-Z-]+)/([0-9a-zA-Z-]+)/([0-9a-zA-Z-]+).html$ $1/$2/$3.php RewriteRule ^([0-9a-zA-Z-]+)/([0-9a-zA-Z-]+)/([0-9a-zA-Z-]+)/([0-9a-zA-Z-]+).html$ $1/$2/$3/$4.php Thanks.
SteveWh msg:4186450 11:41 am on Aug 13, 2010 (gmt 0)
If you want incoming requests for the .php page to receive the .html page instead, your code is backwards. Using just the first example, it should be RewriteRule ^([0-9a-zA-Z-]+)\.php$ $1.html Note the added backslash before the period. I'd probably try this, though, as more general: RewriteRule ^(.*)\.php$ $1.html Can't be sure that's right without testing, but it's a starting point.
g1smd msg:4186703 6:46 pm on Aug 13, 2010 (gmt 0)
You'll need to add a preceding RewriteCond that excludes requests for the Google file URL from being rewritten to an internal PHP file. You'll also need a redirect such that if .php URLs are requested, user is redirected to the .html URL instead. You must add the [L] flag to every rewrite, and the [R=301,L] flags and the target protocol and domain name to every redirect. [
edited by: g1smd at 6:48 pm (utc) on Aug 13, 2010] jdMorgan msg:4186705 6:47 pm on Aug 13, 2010 (gmt 0)
In either case, put a leading slash ahead of $1 if possible. This is a security consideration. Jim