Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsp 我们如何将一个域的所有请求重定向到另一个域的某个部分?_Jsp_Url_Redirect - Fatal编程技术网

Jsp 我们如何将一个域的所有请求重定向到另一个域的某个部分?

Jsp 我们如何将一个域的所有请求重定向到另一个域的某个部分?,jsp,url,redirect,Jsp,Url,Redirect,我们有两个域,example.com和example.net。我们希望对example.net的每个请求都重定向到example.com/example\u section/index.jsp。如何实现这一点?在服务器上的.htaccess文件中 Redirect permanent http://www.example.net/index.jsp http://www.example.com/example_section/index.jsp. 或者您可以在http://www.exampl

我们有两个域,
example.com
example.net
。我们希望对
example.net
的每个请求都重定向到
example.com/example\u section/index.jsp
。如何实现这一点?

在服务器上的.htaccess文件中

Redirect permanent http://www.example.net/index.jsp http://www.example.com/example_section/index.jsp.
或者您可以在
http://www.example.net/index.jsp
翻页并添加

<% 
    String redirectURL = "http://www.example.com/example_section/index.jsp"; 
    response.sendRedirect(redirectURL);
%> 

或者你可以在同一页上写

<jsp: forward page="http://www.example.com/example_section/index.jsp"/>


这将转发页面。

请提供更多详细信息。如果只是重定向,只需通过onclick事件在js中执行即可。onclick='window.location.href=”“'就像您可以使用的那样。
.htaccess
文件只有在您的servletcontainer前面有Apache HTTPD时才有效(因为
.htaccess
文件是特定于Apache HTTPD的,在Tomcat上不起作用等等)。scriptlet方式将起作用,但首选的方式是
过滤器
like。
jsp:forward
完全是服务器端的,不会反映浏览器地址栏中的URL更改。