Forum Moderators: phranque
DocumentRoot: E:\Webs\cfRoot\
\neodude\v5b\.htaccess:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /neodude/v5b
RewriteRule ^about$ about/ [R]
RewriteRule ^about/$ about.cfm
--
Effectively, I want:
http://localhost/neodude/v5b/about
to redirect externally to:
http://localhost/neodude/v5b/about/
that would interally redirect to:
http://localhost/neodude/v5b/about.cfm
The /about/ -> about.cfm part works.
However, the redirect from /about -> /about/ gives me:
http://localhost/E:/Webs/cfRoot/neodude/v5b/about/
If a remove the [R] from the RewriteRule ^about$ about/ [R], it works, albeit doing a totally internal redirect from /about -> /about/ -> about.cfm.
How come Apache includes the entire physical path into the request? Is there anyway I can force a redirect from /about to /about/ externally?
Welcome to WebmasterWorld!
> Is there anyway I can force a redirect from /about to /about/ externally?
No.
By definition, a redirect is a server-client-server transaction. The server sends the new URL to the client in a response with a 301 or 302 status header, and the client uses that URL to re-request the desired resource from the new URL. As such, the server must send the canonical URL to the client.
An internal rewrite is simply the substitution of a new filepath for the resource, and as such, it has to be local.
It sounds like you may have one of several common problems here, because "example.com" should always resolve to "example.com/". This is done by mod_dir, so check that mod_dir is loaded on your server.
A second problem comes up if you have UseCanonicalName on. This can sometimes cause trouble. Try setting it to off.
The third thing that often causes trouble is content-negotiation. If you have Options All or Options MultiViews set, and you don't need multiviews, turn them off.
I'm guessing at your ultimate goal here. It's not clear why you want or need two RewriteRules to accompish your stated goal.
Jim
--
if I take off this rule:
RewriteRule ^about$ about/
I get a 404 error for
[localhost...]
But OK for
[localhost...]
--
My ultimate goal(s) are:
1. all /about requests are redirected externally, so the user is aware, to /about/. To encourage good URL writing practises.
2. all /about/ requests interally rewrite to about.cfm. This is URL beautification.
Number 2 works now; its just that I can't force an external redirect for number 1.
Any possible solutions?