如何在JBoss服务器上重写URL?

时间:2021-05-14 08:52:00

I would like to redirect/rewrite this two kinds of URLs:

我想重定向/重写这两种URL:

  • mydomain.com -> newdomain.com
  • mydomain.com - > newdomain.com

  • mydomain.com/specificPage -> newdomain.com/newSpecificPage
  • mydomain.com/specificPage - > newdomain.com/newSpecificPage

  • mydomain.com/anyOtherPage -> mydomain.com/anyOtherPage (no redirect here)
  • mydomain.com/anyOtherPage - > mydomain.com/anyOtherPage(这里没有重定向)

So I just want to redirect the root domain to a new domain, and some pages from my domain to some pages on a new domain...

所以我只想将根域重定向到一个新域,将一些页面从我的域重定向到一个新域的某些页面......

How can I do that on a JBoss server ?

我怎么能在JBoss服务器上做到这一点?

4 个解决方案

#1


10  

Have you looked into http://www.jboss.org/jbossweb/modules/rewrite.html? It looks like what you're looking for, and it's pretty similar to Mod_rewrite for Apache.

您是否查看了http://www.jboss.org/jbossweb/modules/rewrite.html?它看起来像你正在寻找的东西,它非常类似于Apache的Mod_rewrite。

#2


3  

You might take a look at this http://code.google.com/p/urlrewritefilter/

您可以查看此http://code.google.com/p/urlrewritefilter/

#3


1  

Sounds like you want to send an HTTP 301 Moved Permanently response.

听起来像是要发送HTTP 301 Moved Permanently响应。

RewriteCond %{REQUEST_URI} ^URI_TO_REDIRECT
RewriteRule redirect=301 NEW_SITE [L]

or similar. The [L] is to tell it to redirect immediately instead of continuing to rewrite.

或类似的。 [L]是告诉它立即重定向而不是继续重写。

#4


0  

If you are routing through apache at all it is possible to use mod_rewrite; you just need to be careful as to where you declare the rewrite rules. Directory configs and .htaccess files won't work; you need it as a global configuration for the entire host. Similar thread on serverfault.

如果您通过apache进行路由,则可以使用mod_rewrite;你只需要小心你在哪里声明重写规则。目录配置和.htaccess文件将不起作用;您需要它作为整个主机的全局配置。 serverfault上的类似线程。

#1


10  

Have you looked into http://www.jboss.org/jbossweb/modules/rewrite.html? It looks like what you're looking for, and it's pretty similar to Mod_rewrite for Apache.

您是否查看了http://www.jboss.org/jbossweb/modules/rewrite.html?它看起来像你正在寻找的东西,它非常类似于Apache的Mod_rewrite。

#2


3  

You might take a look at this http://code.google.com/p/urlrewritefilter/

您可以查看此http://code.google.com/p/urlrewritefilter/

#3


1  

Sounds like you want to send an HTTP 301 Moved Permanently response.

听起来像是要发送HTTP 301 Moved Permanently响应。

RewriteCond %{REQUEST_URI} ^URI_TO_REDIRECT
RewriteRule redirect=301 NEW_SITE [L]

or similar. The [L] is to tell it to redirect immediately instead of continuing to rewrite.

或类似的。 [L]是告诉它立即重定向而不是继续重写。

#4


0  

If you are routing through apache at all it is possible to use mod_rewrite; you just need to be careful as to where you declare the rewrite rules. Directory configs and .htaccess files won't work; you need it as a global configuration for the entire host. Similar thread on serverfault.

如果您通过apache进行路由,则可以使用mod_rewrite;你只需要小心你在哪里声明重写规则。目录配置和.htaccess文件将不起作用;您需要它作为整个主机的全局配置。 serverfault上的类似线程。