简体   繁体   中英

Apache RewriteCond for root no longer working after upgrading to 2.4.6

I have several applications sitting in a directory in Apache. In Apache 2.2 I had it set up so that some routes, including the root route, went to one application and all others went to another application. I've just updated to Apache 2.4 and have updated all my settings for it, however the RewriteCond for the root request no longer appears to work (this definitely on 2.2).

What appears to happening is that the Rewrite condition for the root request (www.foo.co.uk) doesn't appear to get matched anymore, so is falling through to second rewrite rule, which I do not want it to. Have there been any changes to Apache that might affect this?

<VirtualHost *:80>
ServerAdmin foo@bar.co.uk
ServerName www.foo.co.uk

DocumentRoot /var/www/

<Directory /var/www/>
    Options FollowSymLinks -Indexes
    AllowOverride All

    Order allow,deny
    Allow from all

    RewriteEngine On

    RewriteCond %{REQUEST_URI} ^/$                    [NC,OR]
    RewriteCond %{REQUEST_URI} ^/css                  [NC,OR]
    //various other RewriteCond's
    RewriteCond %{REQUEST_URI} ^/robots.txt           [NC]
    RewriteRule (.*) firstWebApp/public/$1 [PT,L]

    # All other URLs should go to the Other application
    RewriteRule (.*) otherWebApp/$1 [PT,L]
</Directory>

LogLevel warn
ErrorLog syslog:local1

Turns out the issue was that I had left the default index.html file in the root folder. I'm not sure why the behavior has changed, but deleting this file caused the rewrite conditions to work correctly again.

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