1

I need to redirect to folders from port 80 to 8080 1. Default index to /somename 2. /admin to /somename

I tried a .htaccess to

RewriteEngine on
Redirect / http://example.com:8080/somename
Redirect /admin http://example.com:8080/someAdmin

But i'm running JSP so the folder name i used is someAdmin (note A uppercase) It's impossible for me to change the path in my code (sorry about it)

Problem So because of this i'm getting error page (CASE sEnSiTive) redirection (Automatically it converts to small case in browser)

AddOn I'll be happy if it .htaccess could mask 8080 port from user via reverse proxy.

RewriteEngine on
RewriteCond  %{SERVER_PORT} !^8080$
RewriteRule ^(.*) http://%{SERVER_NAME}:8080/somefolder%{REQUEST_URI}
Redirect /admin http://%{SERVER_NAME}:8080/someAdmin
  • What operating system? – bahamat Aug 24 '11 at 23:33
1

That's odd that Redirect is behaving like that. I don't have an Apache instance handy right now to verify that mod_alias is supposed to behave like that, but if it's not going to respect case in a target location, then I suppose just use mod_rewrite, since you're loading it anyway:

RewriteBase /
RewriteRule ^$ http://example.com:8080/somename [R,L]
RewriteRule ^admin$ http://example.com:8080/someAdmin [R,L]

For reverse proxying, it looks like you'd want to proxy instead of, as opposed to in addition to, the redirects?

For what you need, ProxyPass would work just fine, but it doesn't play nice with .htaccess. If you have the option, don't config this in .htaccess, use ProxyPass instead. If you don't, then mod_rewrite should do the trick:

RewriteBase /
RewriteRule ^admin(.*)$ http://example.com:8080/someAdmin$1 [R,L]
RewriteRule ^(.*)$ http://example.com:8080/somename/$1 [R,L]
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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