Jer*_*dev 3 apache .htaccess mod-rewrite ubuntu-12.04
我正在尝试使用 htaccess 在我的域的子文件夹中重写对 main.php 的所有请求。我的 .htaccess 中的代码如下:
RewriteEngine on
RewriteBase /public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . main.php [L]
Run Code Online (Sandbox Code Playgroud)
我确定模块已启用,我已经使用apache2ctl -M命令进行了检查
root@vps847:/etc/apache2/sites-available# apache2ctl -M
Loaded Modules:
core_module (static)
log_config_module (static)
logio_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
alias_module (shared)
auth_basic_module (shared)
authn_file_module (shared)
authz_default_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cgi_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
mime_module (shared)
negotiation_module (shared)
php5_module (shared)
reqtimeout_module (shared)
rewrite_module (shared)
setenvif_module (shared)
ssl_module (shared)
status_module (shared)
Syntax OK
Run Code Online (Sandbox Code Playgroud)
在我的默认站点中,我添加/编辑了以下几行:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /var/www/public>
AllowOverride All
</Directory>
Run Code Online (Sandbox Code Playgroud)
每次编辑后我都重新启动了apache。然而,每次我浏览公共目录时,我都会看到 apache 目录列表。我已经尝试将 .htaccess 添加到我的 apache 的根目录,但它也不起作用。当我向 .htaccess 文件添加错误时,我确实收到了内部服务器错误。
有人能找出我的配置有什么问题吗?我正在使用 Ubuntu 服务器 12.04。
里面有这个/public/.htaccess:
DirectoryIndex main.php
RewriteEngine on
RewriteBase /public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . main.php [L]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11754 次 |
| 最近记录: |