How to rewrite URL in Tomcat 6 - apache

I'll build a web application and I want to use url rewriting.
In apache this is done with mod_rewrite.
But how can I rewrite urls with Tomcat 6?
I want to use Struts 2 framework.

I've used UrlRewriteFilter as a critical component of a couple of my tomcat-based apps, and have been totally happy with it.

You can do wildcard mappings in your struts.xml:
<action name="*Crud" class="example.Crud" method="{1}">
...
Then I think you can set your default action extension to / in struts.properties:
struts.action.extension=/
As for the URL filter, here's a good blog post.

It could be a good idea to have Apache as a web server for static content in front of Tomcat application server.
You can then use Apache's mod_rewrite and Tomcat.
In any case, there's a similar question.

Related

IIS Reverse Proxy on top site

I have a site (ex: a.domain.com) with multiple applications inside (ex: a.domain.com/App1, a.domain.com/AppX).
I need to figure out how to do a reverse proxy on the top site, only when the people try to access a.domain.com. If someone wants to access a.domain.com/App1 the reverse proxy will have no effect.
Thanks in advance!
May I know how did you set the reverse proxy?
In IIS, we usually use URL rewrite rule to build the reverse proxy.
If you only require reverse proxy rule only take effect on the root www.doamin.com. Then you should add an <add input="{URL}" pattern="^(/)?$" />condition pattern in your rule or include all folder/URL under the top site. Otherwise you have to use regex expression to exclude all 288 applications manually. IIS won't be able to detect sub-application collection and add them to URL rewrite rule automatically.

Correct Apache Configuration And Htaccess

I've just reset my Ubuntu 14.04 LAMP server hosted with digital ocean. Could someone tell me the 'proper' way to do server configuration. My goal is to do everything as clean as possible (and hopefully well structured).
I intend on using the server mainly for programming and data analytics, however I do plan on hosting my website in /var/www/html. I also plan on using letsencrypt/certbot to get an easy SSL. With this in mind, these are the main goals I would like to accomplish:
1) Redirect the website to ALWAYS be served through https AND www.
2) Enable HSTS for the entire website.
3) Enable clean url's (remove .php extensions and what not).
Since I would like all of these properties to be used across the entire website, should the configuration be done inside of the /etc/apache2/ folder? Or should it be done inside of .htaccess?
And if it should be done inside of apache2 configuration, which file should I add it to? And finally, how exactly should it be added? (for example vhost 80/443, inside of a mod_something section, etc).
Thank you in advance, I would appreciate and consider any advice about Apache and htaccess!

Apache like Rewrite Rules in Openshift

I have configured Jboss7 on Openshift yesterday. All I need to have an internal rewrite rule to have /members.html -> members.jsp.
This requires user to see members.html while the actual file(members.jsp) is served by Jboss itself.
Dont know correctly how to setup mod_jk if required but surely I would like this thing to work anyways as I have urls submitted in google and shifting site on openshift should not require me to change the URLs.
I don't think you have access to the Apache configuration on the server. You would need root permissions for that. Have you considered an alternative approach via a web application filter. There is UrlRewriteFilter - http://tuckey.org/urlrewrite/ - which might solve your problem.

Help With 301 Redirection on Plesk Servers (eUk Host Specifically)

I am running around in circles here, I wonder if anyone can help.
I recently moved a static html website to Umbraco. It is running on a Windows plesk shared plan.
I need to put in place 301 redirects for the old content to the new but:
Umbraco won't receive requests for.html, there doesn't appear to be a way to do this.
I can't get any server side running in the .html files that the plesk supports as custom error docs.
I was going to use client side meta redirects, but wasn't sure if Google etc will read these right?
I haven't used it myself, but the Umbraco 301 Moved Permanently project looks like it does what you need.
The real trick will be piping all requests for .html files through ASP.Net. I'm not sure if this can be done with your web host. But some tips can be found here:
http://our.umbraco.org/projects/developer-tools/301-moved-permanently/feedback/7271-when-the-old-pages-are-not-from-umbraco
p.s. You are correct that a client-side redirect will not help with SEO.
you could add a rule in to your UrlRewriting.config the file sits here in the Umbraco installation... "~config/UrlRewriting.config"
The rule would strip the .html extension from the page request. And would look something like the following...
<add name="removehtml"
virtualUrl="^~/(.*).html"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/$1"
ignoreCase="true" />
You would also have to make sure that the web.config file had the following key set to true
<add key="umbracoUseDirectoryUrls" value="true"/>
This would allow you to recreate your url structure with nodes inside the umbraco cms without the html or aspx extension. If all this seems too complex you could individually add each page you want to listen for to the corresponding node in the URL Alias property (umbracoUrlAlias). Umbraco will take this and redirect to your page.

Configuring Mass Virtual Hosting + SSL on development machine

Is there a way to use this, or something like it, for SSL enabled hosts?
VirtualDocumentRoot /www/vhosts/%0/public
I want to avoid having to configure Apache every time I start working with a new domain on my development box. It would be nice to just add a directory, follow standard naming conventions, and be able to automatically access the site with HTTP or HTTPS.
I realize this definitely isn't the route to go for a production server, but it should be ok just for development.
One example came pretty close using mod_rewrite, but it still requires updating a configuration mapping file when you add a host (which I'm trying to avoid).
http://sweon.net/2008/01/hosting-multiple-ssl-vhosts-on-a-single-ipportcertificate-with-apache2.
Any ideas?
Thanks
The author of the article I referenced above was nice enough to come up with a solution.
This is working on Apache 2.2:
RewriteRule ^/(.*)$ /var/www/%{HTTP_HOST}/htdocs/$1 [E=VHOST:${lowercase:%{HTTP_HOST}}]