2

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 http://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 www.bbrown.spsu.edu
RewriteEngine On
RewriteRule ^(.*)$ http://ksuweb.kennesaw.edu/faculty/rbrow211%{REQUEST_URI} [L,R=301]
</VirtualHost>

<VirtualHost *:80>
ServerName bbrown.kennesaw.edu
ServerAlias www.bbrown.kennesaw.edu
RewriteEngine On
RewriteRule ^(.*)$ http://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:
http://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 http://ksuweb.kennesaw.edu/faculty/rbrow211/
http://bbrown.spsu.edu/it3203/2016_02/lab_7s.html
http://bbrown.kennesaw.edu/it3203/2016_02/lab_7s.html

but these two, with two levels of directory, work as expected:
http://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?

6
  • Change ksuweb.kennesaw.edu/faculty/rbrow211%{REQUEST_URI} to ksuweb.kennesaw.edu/faculty/rbrow211/$1 and see if that works better. Cheers!!
    – closetnoc
    Commented May 6, 2016 at 12:04
  • 1
    All these appear to redirect OK for me (ie. http://bbrown.kennesaw.edu/it3203/2016_02/lab_7s.html redirects to http://ksuweb.kennesaw.edu/faculty/rbrow211/it3203/2016_02/lab_7s.html). So, this would seem to be 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)? The redirect code looks OK. The RewriteRule pattern could perhaps be simplified to .* or even ^ - but that won't make any difference in usage.
    – MrWhite
    Commented May 6, 2016 at 12:11
  • @w3dk: You are right! Thank you! I guess that means this question should be closed, or should I delete it? (Not sure if I can delete it.)
    – Bob Brown
    Commented May 6, 2016 at 12:47
  • @BobBrown Rather than delete it, I've added that as an answer, with a bit extra. Caching is a common pitfall when dealing with 301 redirects, so may help to serve as a reminder for other readers.
    – MrWhite
    Commented May 6, 2016 at 13:45
  • 1
    @closetnoc Careful of those slashes. Since this directive is directly in the server config (not per-directory / .htaccess) then $1 will already contain the slash prefix in this instance.
    – MrWhite
    Commented May 6, 2016 at 13:56

1 Answer 1

2

All these appear to redirect OK for me (ie. http://bbrown.kennesaw.edu/it3203/2016_02/lab_7s.html redirects to http://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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.