admin管理员组

文章数量:1410737

I am facing a particular request from the SEO team of a client and I need to handle two different CMS served on the same domain. Basically, the "root" cms is already configured in order to map all requests on the first CMS, where an .htaccess configuration is then handling the url in order to map proper parameters to the system.

The second CMS should act when the url contains a specific string, but the particular request is that the string is not at the beginning of the url, but has some parameters before. So I cannot use the Alias directive as other directories in the VirtualHost configuration and I am considering using AliasMatch instead.

To recap, the second CMS should serve responses when a url matches the "second-cms" keyword in the url:

/param1/param2/second-cms/param3/param4/param5/...

My tentative is to use this configuration in the VirtualHost:

    AliasMatch /second-cms/ /var/www/second-cms/

    <Directory /var/www/second-cms/>
        AllowOverride all
        Order allow,deny
        Require all granted
        Allow from all
        Options FollowSymLinks
    </Directory>

But what I get is an infinite redirect loop - in the browser address bar I see the url followed by repeated /index.html/index.html/index.html/index.html and so on string.

Please note that in the /var/www/second-cms/ dir there is also a .htaccess file (created and working in dev environment, with a simple Alias directive in the VirtualHost configuration) like this:

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    Options +Indexes
    RewriteEngine on

    RewriteCond %{REQUEST_URI} \.html$ 
    RewriteCond %{HTTP_REFERER} ^(https?://[^/]+/.*/)
    RewriteRule (.*)\.html$ %1$1 [R=301,L]

    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^(.*)$   index.php?uri=/$1    [NC,L,QSA]
</IfModule>

<FilesMatch ".(ico|jpg|jpeg|png|gif|js|css)$">
    Header set Cache-Control "max-age=63072000, public"
</FilesMatch>

At first sight I thought that the redirect loop was because of some conflict between the AliasMatch directive and the .htaccess, but also removing the .htaccess from the destination directory i get the same infinite loop problem.

本文标签: Apache AliasMatch map certain directory when matching specific stringinfinite loopStack Overflow