: Limited 301 Redirect performance in .htaccess? I'm in a situation and haven't been able to find a proper solution after much research. I'm working with a client who just built a new website
I'm in a situation and haven't been able to find a proper solution after much research. I'm working with a client who just built a new website with a different URL structure. After the website was complete, I began to tackle any canonicalization issues for proper SEO and site organization. I was able to solve the www vs non-www version of the site being displayed using .htaccess, which made me feel I would be able to 301 all of the old URLs to their corresponding new URLs. I was wrong. I haven't been able to get a single 301 redirect to perform through .htaccess. Instead, I get a 404 page with little clues that reveal my client may be on an IIS server, which I think is a little strange because the .htaccess is working(somewhat).
I'm hoping that it's just the syntax of my .htaccess file to solve www vs non-www that's stopping all other 301 redirects from being completed. Here is what the current .htaccess file looks like.
RewriteEngine On
RewriteBase /
Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ www.example.com/ [R=301,L]
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ www.example.com/ [L,R=301]
Is there anything I've unintentionally added above that would interfere with doing a 301 redirect for other URLs? Such as:
Redirect 301 /old.htm www.example.com/products/side-by-side.htm
Within some of the new product directories exists .htaccess files that are rewriting PHP URLs into cleaner, user friendly URLs. Could this have an effect?
More posts by @Ogunnowo487
1 Comments
Sorted by latest first Latest Oldest Best
I ended up solving the problem. The below syntax does not work:
Redirect 301 /old.htm www.example.com/category/new.htm
However, this syntax works:
RewriteRule old.htm /products/new.htm [R=301,L]
I'm not really sure why the first example doesn't work, but the second works. Perhaps, it's because the .htaccess is on an IIS server and only understands certain syntax structures for redirects. I feel it's also important to note that the beginning of the old URL for the working redirect does not start with a slash, this may be due to the "RewriteBase /" line in the file.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.