Apache .htaccess mod_rewrite在子目录中不工作
我正在尝试使用htaccess将所有请求重写到我域的子文件夹中的main.php。my.htaccess中的代码如下所示:Apache .htaccess mod_rewrite在子目录中不工作,apache,.htaccess,mod-rewrite,ubuntu-12.04,Apache,.htaccess,Mod Rewrite,Ubuntu 12.04,我正在尝试使用htaccess将所有请求重写到我域的子文件夹中的main.php。my.htaccess中的代码如下所示: RewriteEngine on RewriteBase /public RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . main.php [L] 我确信模块已启用,我已使用apache2ctl-M命令进行了检查 root@vps847:/etc/a
RewriteEngine on
RewriteBase /public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . main.php [L]
我确信模块已启用,我已使用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
在我的默认站点中,我添加/编辑了以下行:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /var/www/public>
AllowOverride All
</Directory>
选项索引跟随符号链接多视图
允许超越所有
命令允许,拒绝
通融
允许超越所有
每次编辑完某个内容后,我都会重新启动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]
我遇到了这个问题,并发现有效的解决方案是:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /tools/admin
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /tools/admin/index.php [L]
希望这对某人有所帮助谢谢,这很有效。我不知道为什么我的代码不起作用。我提供的.htaccess也位于/var/www/public。谢谢!:选项+FollowSymLinks-多视图应将此文件放在何处?在根文件夹还是子文件夹中?