简体   繁体   中英

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...

In my phpinfo(), I have:

Loaded Modules: mod_rewrite 

My .htaccess:

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

My Apache config:

<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. You want to turn Multiviews off if you want that to work:

Options -Multiviews

at the top of your htaccess file, or remove it from your <Directory> container:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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