Mobile app version of vmapp.org
Login or Join
Sims2060225

: Apache 2 mod_rewrite Inconsistent Results My former university, SPSU, was "consolidated" into Kennesaw State University. I used to have the domain bbrown.spsu.edu. As a temporary fix, bbrown.kennesaw.edu

@Sims2060225

Posted in: #Apache2 #ModRewrite

My former university, SPSU, was "consolidated" into Kennesaw State University. I used to have the domain bbrown.spsu.edu. As a temporary fix, bbrown.kennesaw.edu was set up by University IT. However, the permanent home for my web pages should be ksuweb/faculty/rbrow211. I have administrative control of the server with the two "bbrown" domains. I've put the following into httpd.conf:

<VirtualHost *:80>
ServerName bbrown.spsu.edu
ServerAlias bbrown.spsu.edu RewriteEngine On
RewriteRule ^(.*)$ ksuweb.kennesaw.edu/faculty/rbrow211%{REQUEST_URI} [L,R=301]
</VirtualHost>

<VirtualHost *:80>
ServerName bbrown.kennesaw.edu
ServerAlias bbrown.kennesaw.edu RewriteEngine On
RewriteRule ^(.*)$ ksuweb.kennesaw.edu/faculty/rbrow211%{REQUEST_URI} [L,R=301]
</VirtualHost>


These two URLs behave as I expect, and redirect to the proper internal page on ksuweb: bbrown.spsu.edu/misc/university_success.html http://bbrown.kennesaw.edu/misc/university_success.html

However the first one of these works and the second does not! It redirects to the index page at the top level, i.e. to ksuweb.kennesaw.edu/faculty/rbrow211/ http://bbrown.spsu.edu/it3203/2016_02/lab_7s.html bbrown.kennesaw.edu/it3203/2016_02/lab_7s.html

but these two, with two levels of directory, work as expected: bbrown.spsu.edu/it3123/2016_02/assign_0_classroom.html http://bbrown.kennesaw.edu/it3123/2016_02/assign_0_classroom.html

I am utterly baffled. My question? What have I done wrong?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Sims2060225

1 Comments

Sorted by latest first Latest Oldest Best

 

@Jamie184

All these appear to redirect OK for me (ie. bbrown.kennesaw.edu/it3203/2016_02/lab_7s.html redirects to ksuweb.kennesaw.edu/faculty/rbrow211/it3203/2016_02/lab_7s.html). So, this would seem to suggest a local caching issue. If you've previously experimented with erroneous 301 redirects, then these will have been cached by the browser and possibly any intermediary caches.

To avoid caching, either test with 302 (temporary) redirects. Or test with browser caching disabled. (In Google Chrome, you can open the Object Inspector and on the "Network" tab, check the "Disable cache" option.)

The redirect code looks OK. The RewriteRule pattern could perhaps be simplified to .* or even ^ (since you aren't using the captured group in the substitution) - but that won't make any difference in usage.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme