Skip to content

Instantly share code, notes, and snippets.

@adhpawal
Last active December 20, 2015 11:53
Show Gist options
  • Save adhpawal/58d3a1faa132de38bb92 to your computer and use it in GitHub Desktop.
Save adhpawal/58d3a1faa132de38bb92 to your computer and use it in GitHub Desktop.
Sometime we need to rewrite the URL to strip the context-root from the URL.This block of code works on the Virtual Host which has proxy connection to Application Server using AJP . We are creating solution for achieving :: example.com/helloworld ==> example.com. Please make sure you have enabled the rewrite engine for Apache.
<VirtualHost *:80>
ServerName example.com
ErrorLog ${APACHE_LOG_DIR}/error_ci.log
CustomLog ${APACHE_LOG_DIR}/access_ci.log combined
ProxyPass / ajp://localhost:8009/context-root/
ProxyPassReverse / ajp://localhost:8009/context-root/
RewriteEngine On
RewriteCond %{THE_REQUEST} /context-url/
RewriteRule ^/context-url/(.*)$ /$1 [R]
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment