Reputation: 21
i have problem with my site, when i try to convert php to html, i got this error Not Found
and this is .htaccess
RewriteEngine on
RewriteRule ^(.*)\.php$ /ver1/$1.html [R=301,QSA,L]
all files in folder ver1
i see this post
but not work with me
i just need convert php to html and if i go to index.php
i go to index.html and make all url html
Upvotes: 2
Views: 4564
Reputation: 1811
Rename your .php file to .html and add this line in your .htaccess
AddType application/x-httpd-php .html .htm
Upvotes: 4
Reputation: 610
Try it on .htaccess:
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*)\.html$ /$1.php
Upvotes: 0
Reputation: 1575
Are you looking for "How do I rewrite .php to .html using .htaccess rules"????????????????
If yes, use
RewriteEngine on
RewriteRule ^(.*)\.html$ /ver1/$1.php [nc]
Upvotes: 0
Reputation: 1063
You need to add /ver1/ in both places - "^(.).php$" -> "^/ver1/(.).php$"
But that line just turns off the .php version - you never copied the line that tells it to actually serve the PHP files under the different extension (RewriteRule ^(.*).html$ $1.php)
RewriteEngine on
RewriteRule ^/ver1/(.*)\.html$ /ver1/$1.php
RewriteRule ^/ver1/(.*).php$ /ver1/$1.html [R=301,QSA,L]
The first rule will internally map .html to .php files and serve them directly to the client
The second rule will REDIRECT anything .php under /ver1/ to it's .html equivalent for SEO purposes
Edit - Warning - if you have any HTML forms that are action=POST data - you MUST update their action to point to the .html version - otherwise they will stop working (POST data is not redirected!)
Upvotes: 0