htaccess 301 Redirect Cpanel to Wordpress - wordpress

I have a site at mysite.com with blog entries in the form of:
mysite.com/year/month/title.html
I want to redirect all these blogs to
wordpress_site.com/year/month/title/
I have added this to my .htaccess file in my public_html folder through Cpanel:
## 301 Redirect Entire Directory
RedirectMatch 301 mysite.com(.*) wordpress_site.com/$1
But the redirect does not seem to be working - what am I missing here?
Thanks!

The hostname isn't part of what gets matched by the regex, try:
RedirectMatch 301 ^/([0-9]+)/([0-9]+)/(.*)\.html$ http://wordpress_site.com/$1/$2/$3/

Related

Setup 301 redirect for .html pages Wordpress

Hi I have migrated my store from Magento to Wordpress, I want to set up 301 redirects for the product pages they were /product.html but now are just /product I used the following code in the .htaccess file, which works but it makes the homepage break, how can I alter this code to make the homepage still work?
redirectMatch 301 ^(.*).html$ $1
You can ignore the index page:
redirectMatch 301 ^(?!/index\.html$)(.*)\.html$ $1

Wordpress change permalinks and redirect new urls 301

I was using this WordPress permalink string.
/%postname%-%post_id%.html
but now I want to change it to, and redirect all old url's to new url's
/%postname%.html
Sample old url is;
http://www.example.com/dead-trigger-2-hile-mod-apk-indir-1890.html
The new url will be;
http://www.example.com/dead-trigger-2-hile-mod-apk-indir.html
My htaccess file currently using default wordpress vars. How can redirect all my urls to new urls 301.
I tryed to use this, but its not working
RedirectMatch 301 ^/(.*)-([0-9]{4})$ http://www.example.com/$1
Try the following
RedirectMatch 301 ^/([^/]+)-(\d+)/$ http://example.com/$1
By following code you will be able to achieve 301 redirect via .Htaccess :
Syntax :
Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html
Example :
# BEGIN 301 Redirects
Redirect 301 /dead-trigger-2-hile-mod-apk-indir-1890.html http://www.example.com/dead-trigger-2-hile-mod-apk-indir.html
# END 301 Redirects

301 redirect to a new link in the website

Hello i want to redirect the following url
example.com/2015/07/new-post.html
to
example.com/2015/07/new-post/
Thanks in advance.
Found a working solution
to change the extension from html to php
RedirectMatch 301 (.*)\.html$ http://www.example.com$1.php
to simply remove .html extension from url
RedirectMatch 301 (.*)\.html$ $1
And godaddy users have to add the following code in the beginning
Options +MultiViews

301 redirects from a flash site (.swf) to wordpress site

I am trying to get 301 redirect to work from an old flash site to new wordpress site.
If I place
Redirect 301 / http://newsite.com
it redirects everything; however new urls are different than old ones.
So I would get a lot of 404's.
For instance:
Redirect 301 /oldlink.swf http://newsite.com/old-link
doesn't work.
Try RedirectMatch directive with regex to pass old path to a new :
RedirectMatch 301 /([^.]+).swf$ http://newsite.com/newurl
This will redirect old http://oldsite.com/foo.swf to http://newsite.com/newurl

301 Redirect htaccess Change URL Structure

I'd like to redirect all pages from a Wordpress multi-site installation to another Wordpress installation - e.g. website.com/blog/blog/page to website.com/our-blog/page
Using redirect 301 / http://www.website.com/our-blog/ doesn't work because the visitors are redirected to website.com/our-blog/blog/blog/page. Does anyone know how to remove the /blog/blog?
Thank you!
You can use RedirectMatch:
RedirectMatch 301 ^/blog/blog/(.+)$ http://www.website.com/our-blog/$1

Resources