htaccess 密码保护和 mod 重写?
我想知道如何解决以下问题。 在我的服务器的根目录中有一个名为 upload.php 的文件,
我希望能够在我的 URL 中添加“/upload”(不带 .php),并且浏览器应该要求输入密码(如果可能的话,可能还需要用户名)。我正确输入密码(和用户名),upload.php 应该打开。
htaccess 可以做到这一点吗?
i wonder how i can solve the following problem.
on the root directory of my server lies a file calles upload.php
i want to be able to add a "/upload" (without .php) to my URL and the browser should ask for a password (and maybe username if possible). I i enter the password (and username) correctly upload.php should be opened.
Is this possible with htaccess?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这是两个不同的问题。
第一:删除.php扩展名
主要有两种方法。
Options +MultiViews
启用它。如果您允许覆盖此选项,请在 http.conf 或 .htaccess 中阻止。RewriteRule ^upload$ upload.php
。这也可以放在RewriteEngine on
启用重写引擎。秒:需要身份验证
您可以使用 PHP 和 Apache 来完成此操作。
:
Yes, both those are two distinct questions.
First: remove the .php extension
There are mainly two ways of doing this.
Options +MultiViews
in a <Directory> block in http.conf or .htaccess if you allows override for this option.RewriteRule ^upload$ upload.php
. This can also be put in a <Directory> block in http.conf or .htaccess (if activated). You will need to have enabled mod_rewrite and the rewrite engine withRewriteEngine on
.Seconds: require authentication
You can do this both with PHP and Apache.