URL重写在我的apache2中不起作用

时间:2013-09-12 14:51:03

标签: php apache url url-rewriting

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

在我的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>

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

非常感谢你!

1 个答案:

答案 0 :(得分: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>