简体   繁体   中英

.htaccess issue Redirect 301 -

We've restructured our site and tried to implement Redirect 301, but to no avail. Seems pretty straight forward, but pages won't redirect and when we vaildate an example URL, status 200 still shows on original page.

Here's the code we are using:

AddHandler server-parsed .htm .html
DirectoryIndex index.jsp index.htm /index.jsp

    RewriteEngine On 
    # Redirect to preferred www example 
    RewriteCond %{HTTP_HOST} ^example\.com 
    RewriteRule (.*) https://example.com/$1 [R=301,L] 

    Redirect 301 /products/manufacturer_1.jsp https://www.example.com/brands/manufacturer_1.jsp

The HTTP to HTTPS rewrite works fine, but the Redirect 301 does not. There are no other rewrites or redirects, so should not be any conflicts.

Any suggestions would be helpful and thanks in advance for the help.

Best, Matthew

Since we are using JSP pages. The Redirect 301 within the .htaccess was never being processed. Therefore, we had to embed the the following code on our pages:

<%
response.setStatus(301);
response.setHeader( "Location", modelUrlString );
response.setHeader( "Connection", "close" );
%>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM