简体   繁体   English

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

[英]URL Rewriting don't work in my apache2

I have a problem with my apache2, the url rewriting don't work and I don't know why... 我的apache2出现问题,URL重写不起作用,我也不知道为什么...

In my phpinfo(), I have: 在我的phpinfo()中,我有:

Loaded Modules: mod_rewrite 

My .htaccess: 我的.htaccess:

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

My Apache config: 我的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>

I think my config is right, but I really don't know why my rewriting don't work... Have you an idea ? 我认为我的配置是正确的,但是我真的不知道为什么我的改写不起作用...你有想法吗?

Thanks you so much ! 非常感谢 !

For this particular rule: 对于此特定规则:

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

Mod_negotiation is going to try to deal with it for you. Mod_negotiation将尝试为您处理它。 You want to turn Multiviews off if you want that to work: 如果您希望Multiviews off它:

Options -Multiviews

at the top of your htaccess file, or remove it from your <Directory> container: 在htaccess文件顶部,或将其从<Directory>容器中删除:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM