0

我的 apache2 有问题,url 重写不起作用,我不知道为什么......

在我的 phpinfo() 中,我有:

Loaded Modules: mod_rewrite 

我的.htaccess:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^test\.html$ /test.php [L]

我的 Apache 配置:

<VirtualHost>
        ServerAdmin mail@gmail.com
        ServerName www.site.com
        ServerAlias site.com
        DocumentRoot /var/www/site.com/

        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /var/www/site.com/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride All
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

我认为我的配置是正确的,但我真的不知道为什么我的重写不起作用......你有什么想法吗?

非常感谢 !

4

1 回答 1

1

对于此特定规则:

RewriteRule ^test\.html$ /test.php [L]

Mod_negotiation 将尝试为您处理它。Multiviews off如果你想让它工作,你想转:

Options -Multiviews

在您的 htaccess 文件的顶部,或将其从<Directory>容器中删除:

    <Directory /var/www/site.com/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>
于 2013-09-12T14:54:18.143 回答