htaccess: Redirect file.php to file.html, and block direct access to the file.php at the same time
I would like to redirect a url help.html to help.php (internally) using .htaccess rewrite, but at the same time, I would like to give a 404 error message if someone tries to access help.php directly.
I've seen alot开发者_Go百科 of tutorials, and alot of questions answered, but none to this specific problem.
Is this possible?
Edit: For someone looking at the url from the outside, he would only see that help.html exists, but not help.php (even though internally only help.php exists, but not help.html) :)
<Files help.php>
order allow,deny
Allow from 127.0.0.1
deny from all
</Files>
RewriteEngine On
RewriteRule help.html$ help.php [L]
And you might wanna add
AddType application/x-httpd-php .html
to make the PHP execute now show as HTML/TEXT.
Edit:
And you can give 404 error (cuz this htaccess will give 403 error) by adding this ErrorDocument 403 404.php
and put 404 error HTML code in that page
in your .htaccess file, you can use "permanent redirect" command:
Redirect 301 /help.php /help.html
use a meta tag redirect to the help.html page from the help.php (404 page) after x seconds
<meta HTTP-EQUIV="REFRESH" content="10; url=http://www.yourdomain.com/help.html">
精彩评论