1
我喜欢阻止除“index.php”之外的我的网站的所有“.php”请求,我如何使用.htacess和重写mod?Apache .htaccess - 使用“.php”而不是“index.php”阻止所有URL
RewriteEngine On
RewriteCond %{REQUEST_URI} ^.*(.php) [NC]
RewriteRule ^(.*)$ - [F,L]
我喜欢阻止除“index.php”之外的我的网站的所有“.php”请求,我如何使用.htacess和重写mod?Apache .htaccess - 使用“.php”而不是“index.php”阻止所有URL
RewriteEngine On
RewriteCond %{REQUEST_URI} ^.*(.php) [NC]
RewriteRule ^(.*)$ - [F,L]
可以在RewriteRule
使用否定条件图案:
RewriteEngine On
RewriteCond %{REQUEST_URI} \.php$ [NC]
RewriteRule !^index\.php$ - [F,NC,L]
我用了多年,它完美的作品。您可以添加多个文件以允许使用|分隔列表
#PROTECT FILES
<Files *.php>
Order Deny,Allow
Deny from all
</Files>
#ALLOW FILES
<FilesMatch index.php|captcha.php>
Allow from all
</FilesMatch>
您的解决方案可能是在这里:拒绝所有文件,但htaccess的指数/默认页](http://stackoverflow.com/a/12115091/4973076) – mdck
或可能有:HTTP://计算器.COM /问题/ 12865780/MOD重写的异常换一个特定的文件 – mario