.htaccess 有没有办法做到这一点?[关闭]

l5tcr1uw  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(113)

已关闭。此问题需要details or clarity。目前不接受回答。
**要改进此问题吗?**通过editing this post添加详细信息并阐明问题。

2天前关闭。
Improve this question
解释:现在我正在使用这些规则,但当我试图访问该文件,而不删除扩展名,我可以访问,所以我不想使用,我想保护其安全的原因
示例我的文件名是-(www.dopenews.in/submit.php)如果我访问dopenews.in/submit它提供访问所以我想保护没有扩展名和扩展名。这应该适用于我所有的php文件是有反正.然后帮助我们得到它解决请

php_value date.timezone America/New_York
Options +MultiViews
RewriteEngine on

# For .php & .html URL’s:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L]
RewriteRule ^([^.]+)$ $1.html [NC,L]

# Prevent direct access to PHP files
<FilesMatch "\.php$">
        
# 'https://dopenews.in'

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.php\ HTTP/
RewriteRule .* - [F,L]
</FilesMatch>```

字符串

7bsow1i6

7bsow1i61#

这将是通常的方法,它重定向直接请求:

RewriteEngine on

# externally redirect requests with extension
RewriteRule ^(.+)\.(php|html)$ $1 [R=301,L]

# internally rewrite requests without extensions to ".php" & ".html" URLs:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^.]+)$ $1.php [L]
RewriteRule ^([^.]+)$ $1.html [L]

字符串
当然,你也可以返回一个“Forbidden”而不是重定向,只要使用F标志而不是R=301标志。

相关问题