You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Qwer Uiop <ko...@mail.ru> on 2004/03/07 15:35:36 UTC

[users@httpd] Trailing slash redirect with nondefault port

I run apache as a non root user on port 8080 and forward port 80 to 8080 by firewall. The problem is that then user enter
http://server/dir the server (I guess it is done by mod_dir) redirects him to http://server:8080/dir/. Is it possible to setup things in such a way that the redirect always goes to the same port as the original request?

Probably, I should substitute r->uri with r->unparsed_uri in mod_dir.c:handle_dir (at least in case of no parameters). Is it right way? 

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Trailing slash redirect with nondefault port

Posted by Aaron W Morris <aa...@mindspring.com>.
Qwer Uiop wrote:

> I run apache as a non root user on port 8080 and forward port 80 to 8080 by firewall. The problem is that then user enter
> http://server/dir the server (I guess it is done by mod_dir) redirects him to http://server:8080/dir/. Is it possible to setup things in such a way that the redirect always goes to the same port as the original request?
> 
> Probably, I should substitute r->uri with r->unparsed_uri in mod_dir.c:handle_dir (at least in case of no parameters). Is it right way? 
> 

Had the same problem.  Solved with mod_rewrite:

RewriteEngine on
RewriteCond %{SERVER_PORT} ^8080$
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} -d
RewriteRule ^/(.+[^/])$ http://%{HTTP_HOST}/$1/ [R]

If you are only using port 8080 on your web server, then you can safely 
remove the first rewrite condition.  Frankly, I like this better than 
using "UseCanonicalName on" since it is hostname agnostic.

-- 
Aaron W Morris <aa...@mindspring.com> (decep)



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org