0

I am using Redhat and I am trying to redirect a url in apache tomcat. For Example I have a web address that is http ://example:8282. I want to redirect the page so that when I type http ://example/alfresco it shows http ://example/alfresco in the browser, so that user cannot see the port number. I have been successful in redirecting but not redirecting and keeping the url I want redirected to actual url, that I do not want seen.

Things I have tried in /etc/httpd/conf/httpd.conf

#
Redirect permanent /alfresco http://<ip address>:8282/
#

I also tried

#
RedirectMatch ^/tomcat/(*)$ http://<ip address>:8282/$1
#

I also tried

#
RewriteEngine On
RewriteCond %<ip address>:8282   !^1.1.33.201\/tomcat
RewriteCond %<ip address>:8282   !^$
RewriteCond %8080                !80$
RewriteRule ^tomcat/?$           http://<ip-address> [PT]
#

Thank You, Any help would be appreciated

jbaile33
  • 1
  • 1
  • 3

1 Answers1

0

Because I think there is a fundamental mistake, I will first try to redefine the most important aspects before providing you with solution:

Redirects: You can not hide the port or any URL using only redirects because redirects are doing just that - redirecting. So even if you configure them properly when the user enters http://example/alfresco, he will be redirected to http://example:8282/alfresco.

Ports: When you point your browser to http://example/ it actually loads the host example on port 80 http://example:80/. The only reason the port is hidden is because 80 is the default port for the HTTP protocol so all browsers are set to hide it by default. That is not true for all other ports, when you access http://example:8282/ for example.

Solution: To hide the non-standard port, or any other address you do not want to see, you need to proxy it. For your case I suggest ProxyPass. A working example can be seen here: https://stackoverflow.com/a/7818502/2948573

Grigor Yosifov
  • 1,424
  • 1
  • 10
  • 13
  • I appcreciate your reply. This does work, but not with a directory structure. I am able to go to http:///tomcat but if i click on a link inside tomcat called docs it will try to go to http:///docs which it has an error saying page does not exist because it did not take into account the proxy. It should have went to http:///tomcat/docs. So it does work , only not with a directory structure. – jbaile33 Sep 23 '14 at 22:03