Url redirection in Apache web server.
Here is a small example of url redirection in Apache using proxypass. I used this when I was using Apache as proxy to Apache tomcat using mod_jk.
Example:
you want to forward
www.yourdomain.come/abc to www.yourdomain.com/linux/commands/abc
Here is how you can do it. Open httpd.conf in your favorite editor. Add the following lines.
ProxyPass /abc http://localhost/linux/commands/abc
ProxyPassReverse /abc http://localhost/linux/commands/abc
But while using above solution you may have to give trailing “/” to correct it use the following rewrite rule.
RewriteEngine on
RewriteRule ^/abc$ /abc/ [R]
But for using the above solution you have to load modules mod_proxy and mod_rewrite.
Load the modules, add the rules, restart Apache You are done. Please suggest if you know any better ways to do it. Remember that all my webapps is in tomcat and Apache is just front end.
Recent Comments