Error is .htaccess - Redirects not working and its very strange - apache

My site has just recently launched a bunch of new product pages, replacing the old ones.
Here is an example of a redirect I want. One going from the old page...redirecting to the new page. I checked Google webmaster and said that there was a not found error for the second link.
Redirect 301 /it-infrastructure.html http://www.example.com/managed-enterprise-services.html
Redirect 301 /it-infrastructure http://www.example.com/managed-enterprise-services.html
So the .html one is redirecting fine...but the one without the .html extension is not. BUT...what's strange is that I have a bunch of redirects from the past that don't use the html ext and work fine, such as:
Redirect 301 /broadsoft-web-portal http://www.example.com/broadsoft-web-portal.html
and
Redirect 301 /business-voip http://www.example.com/business-voip.html
Anyone have any idea why this isn't working?

Add to your .htaccess this line
Options -MultiViews

Related

Prevent wildcard in htaccess 301 redirect

I have setup a htaccess 301 redirect to redirect an indexed page to a new page, however this is also acting as a wildcard redirect for child pages which I do no what to happen.
Old structure
example.com/faq
example.com/faq/question-1
example.com/faq/question-2
etc etc
New structure
example.com/faqs
example.com/faq/question-1
example.com/faq/question-2
etc etc
htaccess redirect in place :
Redirect 301 /faq/ https://example.com/faqs/
This is working with no issues to send /faq to /faqs however it is also sending /faq/* to /faqs/* which I do not want to happen.
For example going to example.com/faq/question-1 causes a to many redirects error and finally lands on example.com/faqs/question-1
Is there anything i can add to the single redirect line to prevent this happening, or is their a more complex use of RewriteRule I could use instead. Research into the matter initially seem to confirm that this should/would happen, and if it does what can be added to prevent it. After a prompt to the apache docs I can see why they would redirect as a wildcard.
After suggests from CBroe an implementation of using RedirectMatch worked.
RedirectMatch 301 ^/faq/$ https://example.com/faqs
This now redirects /faq to /faqs, however doesn't redirect /faq/question-1 to /faqs/question-1 etc

.htaccess rules to redirect certain pages and the catch all others

I'm redirecting a site from an old platform to another. It's got 300-400 pages and all the pages have different names.
It's learn.example.com (old platform) to courses.example.com (new platform)
So I've put in some 301s at the beginning of the .htaccess file of the most important pages, for example:
Redirect 301 /courses-overview/ http://courses.example.com/courses
But at the end I need a catch-all to redirect any other page not previously specified as a 301 like learn.example.com/whatever to courses.example.com to catch any of the other 300-400 pages that don't exist in the .htaccess file now.
Is that possible?
You can Redirectother pages via the following Redirect :
RedirectMatch ^/.*$ http://example.com/
Put this bellow your existing Redirects otherwise Apache will redirect your whole site.

htaccess redirecting website.com/folder/content to subdomain.website.com/content

I recently moved a Wordpress blog from website.com/wordpress to help.website.com. Now I want to redirect the links to the old adress to the new adress.
I deleted everything from the /wordpress folder except the .htaccess. This file has the following code:
RedirectMatch 301 (.*) http://www.help.website.com$1
It redirects my old links but I don't know how to remove the /wordpress from them.
For example if I access website.com/wordpress/article-categories/example-article/ it sends me to help.website.com/wordpress/article-categories/example-article/, but I want to get to help.website.com/article-categories/example-article/ instead. How do I achieve this?
Try
RedirectMatch 301 ^/wordpress/(.*)$ http://www.help.website.com/$1
This will match the folder literally without capturing it.

htaccess 301 redirect "works" but I get a 404 error at new site

Sorry for such a long title, but it pretty well describes what is happening.
Details: I have two sites, different domains. Previously, I had a temporary site in a not-visible, but published directory in the older domain. Only those who had the extra directory (or the extra path would normally see the temporary site).
Now that I have a new domain and a permanent new site, I simply want to redirect any attempts to access the old directory/pages/site. Here is the line I added to the old site's htaccess file (last line, BTW):
redirect 301 /mailscamalert.com/weather2/ http://www.mid-southweather.com/
That "works" at least in the sense that the user ends up at the new site. But that site throws up a 404 'flag' and the user ends up at my "erer" page. All the new site's navigation is on that page, of course, but it is probably very confusing!
I've tried removing the trailing "/" on 'weather2/' and/or "...com/", adding
"index.html" to the new site's url. No change in ending up at the error page. Also have tried "meta" redirects and even a bit of php:
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.mid-southweather.com/index.html");
Any helpful suggestions or links, greatly appreciated!
Thanks!
Please correct your rewrite rule to the following:
RewriteEngine On
RewriteRule ^weather2/ http://www.mid-southweather.com/ [R=301,L]
If you had multiple pages in that directory and want them all to redirect to your new target domain, do this:
RewriteRule ^weather2/.* http://www.mid-southweather.com/ [R=301,L]
Your current rewrite rule appears to append the actual directory you are trying to redirect to the target url.
Location: http://mid-southweather.com/weather2/
As I discovered using live http headers extension. That weather2 directory of course doesn't exist on your new site, thus the 404.
Just dump your lines and replace them with mine and it should all work nicely. And undo any other changes you may have done in the process of trying to get it working.
Make sure you don't have other rewrite rules going on, it looks to me like you might have one more running somewhere.

Apache mod_rewrite help with Wordpress

I administer my wife's site, namelymarly.com. Up until last week, the root page of the blog was namelymarly.com/blog/.
Last week I changed it in the WP settings to be namelymarly.com.
WP created the new htaccess file, and I moved the index.php to the root directory (but left the WP folder where it was in the /blog/ directory), as instructed. Everything is working great except for one very important thing:
When you type 'namelymarly.com/blog/' into a browser now, you get a 404 error.
All other URLs, when they include the '/blog/somethinghere', will redirect properly to '/somethinghere.' It's only when there's nothing after '/blog/' that there's a problem.
I tried adding this rule but it still redirects to the 404 page:
RewriteRule ^/blog/$ /index.php
Any suggestions/help?
install "Redirection" and then add a 301 redirect from namelymarly.com/blog/ to namelymarly.com
Did you follow these diections?: Moving WordPress « WordPress Codex
You don't need the redirection plugin. Wordpress handles redirects if you regenerate permaliks. If you have to, use this in .htaccess before the Wordpress rewrite block:
Redirect 301 /blog http://namelymarly.com
But first, be sure you've reset your permalinks in Dashboard/Settings/Permalinks and make sure that copy the changes to .htaccess yourself and that there is only the most recent - the last - rewrite block in the file (WP has a habit of adding more and more rewrite blocks to .htaccess).
And check the URLs of your other URLs in the post/page editor and see if they contain /blog/