httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Weill <>
Subject [users@httpd] mod_rewrite question on directory
Date Mon, 10 Jun 2019 23:18:01 GMT
We have a test server, with test sites that are in two different branches
of development, but essentially the same base content.  They live at
/x/y/z/testsite and /x/y/z/test-site.  We have other sites such as wikis
and one-offs which need to stay online on our production server, and I have
been testing using rewrites to force the URL to conform to the directory
path that is defined in the .conf file.

So for example, in the testsite.conf file, I have the following:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^/$ [L,R]

alias /testsite "/x/y/z/testsite"
<Directory "/x/y/z/testsite">
Require all granted
RewriteEngine On
RewriteBase /testsite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{HTTPS} Off
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTP_HOST} !
RewriteRule ^.*${REQUEST_URI} [R]

The test-site.conf file is the exact same except for adding the hypen in
the names.

We also have the following in ssl.conf for these:
RewriteRule ^(.*)/testsite$          $1/testsite/ [R,NC]
RewriteCond %{HTTP_HOST}        testsite\.example\.com
RewriteCond %{REQUEST_URI}      ^/testsite(.*)
RewriteRule (.*)      {REQUEST_URI}
RewriteCond %{HTTP_HOST}
RewriteCond %{REQUEST_URI}       ^/$
RewriteRule (.*)        [R]

RewriteRule ^(.*)/test-site$  $1/test-site/ [R,NC]
RewriteCond %{HTTP_HOST}        test-site\.example\.com
RewriteCond %{REQUEST_URI}      ^/test-site(.*)
RewriteRule (.*)      {REQUEST_URI}
RewriteCond %{HTTP_HOST}
RewriteCond %{REQUEST_URI}       ^/$
RewriteRule (.*)        [R]

If I leave this as shown, and restart the service, neither page loads at
all.  If I comment out the three lines after "RewriteRule ^(.*)/testsite$"
and "RewriteRule ^(.*)/test-site$" respectively, the sites load properly.
We have this exact set of rewrites on ssl.conf for all sites on the
production server and it rewrites the URL properly.  So I'm not sure where
it's failing on the test site.  Logs are set to trace8 on the test server
and I'm not getting anything that helps tells me where the problem is.


View raw message