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.
Related
I need to 301 redirect some old urls to the category archive page.
Here's an example of the old url structure that need to be redirected:
domain.com/vetrina/name-post-1
domain.com/vetrina/name-post-2
domain.com/vetrina/name-post-3
etc.
Since those pages don't exist anymore I simply need to redirect them to the archive page of the category:
domain.com/category/vetrina
What is the correct way to do that in the .htaccess file?
Thank you :)
You can use RedirectMatch directive
RedirectMatch 301 ^/vetrina/.+$ http://example.com/category/vetrina
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
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
I want to change the permalink structure of my site from /%postname%/ to /%category%/%post_id%/%postname%/ , and have the old backlinks redirect to the new structure (currently getting 404's). I have tried a couple of different redirection plugins (Redirection, 301 Simple Plugins) and I can't get them to work.
Can someone show me the rule to put in the htaccess file instead?
Thanks!
If you know the explicit category and post_id for a given postname, then you can create the redirects individually:
Redirect 301 /example-post-name-to-redirect/ /example-category/1234/example-post-name-to-redirect/
or using mod_rewrite (note, these rules must be before your wordpress rules:
RewriteRule ^example-post-name-to-redirect/$ /example-category/1234/example-post-name-to-redirect/ [L,R=301]
But the better solution is just using wordpress to do this for you, have you tried: UrbanGiraffe Redirection plugin, Scott Yang's Permalink Redirect WordPress Plugin, or Yoast's Permalink Redirect WordPress Plugin?
On the Redirection Wordpress Plugin you must add your old structure to Site->Permalink Migrations, something like this:
/%year%/%monthnum%/%postname%/
On the .htaccess file you must use regex like this one:
RedirectMatch 301 /^/\d{4}/\d{2}/(.*) https://yourdomain.com/$1/
I recently transferred my Blogger blog to WordPress, and I want to redirect old Blogger permalinks to the new site.
Old:
http://sitename.com/2012/04/my-post-url.html
To new:
http://sitename.com/my-post-url/
I've tried following .htaccess code. It removes years and months, but doesn't remove .html. Can anyone tell me how to get / instead of .html at the end of the link?
Any modification for the following code?
RedirectMatch 301 /\d{4}/\d{2}/\d{2}/(.*) http://mydomain.com/$1
RedirectMatch 301 /\d{4}/\d{2}/\d{2}/(.*)\.html http://mydomain.com/$1
That should do the trick. :)