Search code examples
apache.htaccessurl-rewritingw3m

Apache rewrite - text browser sees redirection


This isn't exactly a problem, but I'm really curious. I'm doing a simple rewrite in my .htaccess file with the [L] flag. It works fine, as expected in GUI browsers, but I see a quirk when I load the page in w3m. It still redirects as expected, but when I press Shift-U to see the URL, it shows the folder to which it has been redirected. I thought that unless I'm using the [R] flag, the browser would not even know that Apache is pulling the page from a different directory. Am I wrong, or do I have .htaccess configured incorrectly? Here's .htaccess:

RewriteEngine On
Options -Indexes
RewriteRule     ^unicorn/?$      sampler/cs5.html [L]
RewriteCond     %{REQUEST_URI} !^/addip/?$
RewriteCond     %{REQUEST_URI} !^/sampler/
RewriteCond     %{REQUEST_URI} !^/cs.*
RewriteRule     ^([a-zA-Z0-9]+)$                /makestory/makestory.php?story=$1 [END]

Here's the URL I put in w3m: https://example.com/unicorn. Typical browsers continue to show this in their address bar.

Here's what w3m shows when I press Shift-U: https://example.com/sampler/

Thoughts?


Solution

  • You nailed it, MrWhite! The html doc contained <base href="/sampler/">. I took that out, and w3m now shows example.com/cookie, as expected. I then fixed the reference to the CSS file so that base href isn't needed anyway. Thanks for the insight.