.htaccess redirection rule for WordPress - wordpress

I have moved a WordPress blog from subfolder to a subdomain.
Previous structure : www.sitename.com/fashion-blog
New structure is here :
www.blog.sitename.com
The WordPress has been moved to the root directory of sub domain. How can I redirect visitors using .htaccess so that if some one visits old URLs , they will be redirected to new URLs.
For example if some one visits:
http://www.sitename.com/fashion-blog/some-post.html
they should be redirected to its new URl as:
http://blog.sitename.com/some-post.html

Try putting this in your .htaccess file
RedirectMatch 301 /fashion-blog/some-post.html http://blog.sitename.com/some-post.html

Related

.htaccess 301 not mapping subdirectory assets

I had a WordPress instance hosted on a subdirectory on a domain. I have now changed the domain and moved the WordPress setup to the root of a new domain.
I have set up .htaccess on the old domain root directory as follows.
Redirect 301 /subdirectory https://newdomain.com/
And it's working pretty well. But for some reason, the assets in the subdirectory chain are throwing 403 forbidden. The following pattern ends up with 403.
https://olddomain.com/subdirectory/wp-content/uploads/1.jpg
What I might be doing wrong here?

How to write a .htaccess for URL redirect or rewrite for WordPress site?

I am trying to understand regex URL rewrites and redirects.
I need the following:
www.mydomain.com/tag/*/index.html (for example, mydomain.com/tag/winter-holidays/index.html or mydomain.com/tag/summer-holidays/index.html) to redirect to: www.mydomain.com/index.php/tag/WHATEVER/index.html
www.mydomain.com/*/ (for example, www.mydomain.com/four-roots-of-happy-living/, www.mydomain.com/four-roots-of-happy-living (without the ending slash), www.mydomain.com/living/, www.mydomain.com/living (without the ending slash) AND ALSO www.mydomain.com/category/happiness/ and www.mydomain.com/category/happiness (without the ending slash) to redirect to www.mydomain.com/index.php/WHATEVER/ or www.mydomain.com/index.php/WHATEVER/ WHATEVER/.
I have tried so many different combinations in my .htaccess file that my head is spinning now.
In my .htaccess (currently) I had this, but have deactivated it for the meantime until I can get this straight:
Redirect 301 /* /index.php/*
RedirectMatch 301 /*(.*)/? /index.php/$1
Note: My htaccess file was/is in my root directory, my WordPress site is in a wp folder off that, and it did not have a .htaccess file.

Redirect alias domain sub-folders to main domain sub-folders

I just combined 2 domains into one. i used the phpMyADmin Alias domain
settings (maybe that's the issues) to point the domain to the hosting...
Now, I want old domain / alias domain pages to redirect to corresponding pages in the new domain - this is a Wordpress site
I tried this
redirect 301 gispan-online.co.il/some-category/ http://www.gispanjewelry.co.il/some-category/
but it doesn't work.
I don't know if the problem is that this is a Wordpress site
and need other setting or that the server catches the redirect
before htaccess is loading or that I am just doing it wrong
Would appreciate your help on this matter.
You can use RedirectMatch directive :
redirectMatch 301 ^/(.*)$ http://www.gispanjewelry.co.il/$1/

Wordpress 301 Redirect

I have got one Wordpress blog site and I use permalink as:
%category%/%postname%.html
I want a change as:
%postname%.html
And now old urls (https://www.example.com/category/post-name.html) 301 redirect to (https://www.example.com/post-name.html).
How can I redirect with use .htaccess file?
Just go to wp-admin, then /settings, then /permalinks and select "Post name". More info on that here: https://codex.wordpress.org/Using_Permalinks
For 301 redirects you can write your own to your htaccess file but this is probably not as easy as using a plugin like Simple 301 Redirects.

301 redirect help - .htm removed and few urls changed

I'm moving content from an old dreamweaver site to a new wordpress site, all file names are the same, except the new wordpress one's don't have the .htm at the end.
Some category/subcats slugs are changed.
I'm wanting to 301 the domain and all pages to new domain name.
Most urls:
Old content url: http://olddomain.com/reviews/soft/graphics/filename.htm
Where new page will be: http://newdomain.com/reviews/soft/graphics/filename
A few categories/subcats:
Old: http:// olddomain.com/reviews/hard/sound/filename.htm
New: http:// newdomain.com/reviews/hard/sound-review/filename
What would the 301 htaccess file look like?
(note: both old and new urls have the www. in them, the old domain also needs all non-www redirected too)
Appreciate any help
What would the 301 htaccess file look like?
In the htaccess file in your olddomain.com document root:
RedirectMatch 301 ^/([^/]+)/([^/]+)/([^/]+)/(.*)\.htm$ http://newdomain.com/$1/$2/$3/$4

Resources