我想写一个.htaccess文件,如果请求.php(index.php除外)文件,则返回404。
当请求.html(index.html除外)重定向到index.php。
我没有代码可以显示,因为它没有任何效果。
谢谢
答案 0 :(得分:0)
Apache重写规则可以达到你想要的效果:
RewriteEngine On
# index.php allowed - no more rules to apply
RewriteRule ^index\.php$ - [L]
# if static .html file does not exist, redirect to index.php
RewriteCond %{REQUEST_FILENAME} !-f
# if your web application is served under web root:
RewriteRule \.html$ /index.php [L]
# if your web application has a prefix, substitute @VHOST_WP_PREFIX@:
# RewriteRule \.html$ @VHOST_WP_PREFIX@/index.php [L]
# 404 for other .php files
RewriteRule \.php$ - [R=404]