mod_rewrite 在虚拟目录上不起作用

mod_rewrite 在虚拟目录上不起作用

服务器:运行 apache2 的 ubuntu 10.4

我有一台安装了 mod_rewrite 的服务器,它在我的虚拟主机上运行良好。但我正在开发一个新网站,想在更改名称服务器以指向该服务器之前在服务器上看到它。因此,在默认网站配置中,我添加了

Alias /tester/ "/srv/www/tester.org/wwwroot/"
<Directory "/srv/www/tester.org/wwwroot/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    allow from all
    DirectoryIndex  index.php index.html index.shtml
</Directory>

当我访问 serverIP/tester/ 时,我可以看到该站点,但是使用以下 .htaccess 文件时,除了 index.php 之外,我只会收到“页面未找到”错误。

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /tester/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /tester/index.php [L]
</IfModule>
# END WordPress

我花了大约 2 个小时,但我甚至猜不出我做错了什么。这似乎应该可行。有什么让任何人印象深刻的吗?

答案1

您已设置:

RewriteBase /tester/

但是然后你要重写相同的路径:

RewriteRule . /tester/index.php [L]

因此,您正在重写对的请求/tester//tester/index.php

与其这样,不如试试这个:

RewriteRule . index.php [L]

相关内容