Change permalink structure with htaccess - wordpress? - wordpress

I want to change my old domain name to new domain. What I ask here is how to redirect permalink structure with htaccess from
http://www.OldDomain.com/postname/ to http://NewDomain.com/postid/postname/
/%postname%/ /%postid%/

Straight answer is NO, you must not do this via .htaccess.
Wordpress already supports (and enforces) this permalink structure so it is much better and cleaner to goto Wordpress admin panel and change the permalink structure to /%postid%/%postname%/ in the newer installation of Wordpress.
PS: Note that even if you rewrite these URLs differently via mod_rewrite, WP will enforce and expect this to whatever is defined in it permalink definition.

Related

Make WordPress' default posts go to /blog -- permalinks not working

Consider the following post types
Posts (default in WordPress)
Accessories (Custom post type)
I want posts to go to /blog. Accessories slug has been defined as /accessories.
To achieve this, in settings > permalinks > and have defined my custom structure as /blog/%postname%/.
With this, when I go to /blog/, I get a 404. However, when I create a post in posts, the permalink shows up as /blog/test-title.
Also, with the custom structure set, when I try and go to /accessories, it also 404's.
Questions:
Why does /blog 404? It should use index.php as it's template, no?
Why does /accessories 404 with this change?
How do I get /blog and /accessories working?
To get this WordPress permalink stuff to work correctly, the underlying apache web server grabs the incoming URL requests and rewrites them underneath the covers so they point to /index.php?something=something. For this to work, apache must
have an extension module called mod_rewrite enabled,
be configured to allow rewriting in your WordPress instance, and
be able to write a file called .htaccess in the same folder as your WordPress index.php.
You didn't mention what kind of OS your server lives on, so it's difficult to give you specific advice. You might check Digital Ocean's fabulous documentation for help.

How to redirect links from structure to another

My site Permalinks structure is: /%post_id%/%postname%/
/%post_id%/
and
/%post_id%/%postname%/
are working correctly and showing the same content
I want to redirect every link with
/%post_id%/ structure
to
/%post_id%/%postname%/ structure without change Permalinks structure
Is there any way to do that using WordPress plugin or htaccess code?
The problem has been solved using Redirection plugin
permalink settings
Redirections plugin settings

Redirect /123/POST to just /POST in wordpress using .htaccess Rewrite Rules

I have a website running wordpress with some good amount of posts.
For a specific reason, i setup my wordpress permalinks structure to /%post_id%/%postname%/
Now i want change my permalink structure to /%postname%/ for supporting a plugin Category Subdomain Pro
When i change the change the permalink structure, new links are working but i am getting a 404 error for old urls.
So, i am thinking about redirecting old urls to new urls.
If you know anything about this, please share something and help me resolve this issue.
Sorry for delay, Check this out... Before # BEGIN WordPress in .htaccess file put this code...
Redirect 301 /post_id/postname/ http://example.com/postname/
just replace post_id,postname to your website posts id and post name. Replace example.com with your website name and postname with your postname.
replace for every single post
or you can use plugin Redirection

Rewrite Magento url to Wordpress page

I have a Magento site installed at the root of my domain and a Wordpress installed in a subdirectory. Currently I access my sites like this:
Magento: "domain.com"
Wordpress: "domain.com/blog"
I would like to be able to use Wordpress Pages seamlessly, without the "/blog" subdirectory showing in the url, such as:
Wordpress Page-X: "domain.com/page-x"
Note that I do want to keep the "/blog" subdirectory showing normally for blog posts etc... I just don't want it for Wordpress Pages.
Could anybody help on how to set that up? I was think tweaking the .htaccess would've work, but I can't find out how. Other solutions are welcome too. Thank you.
Magento provides you with an option to create custom URL rewrites in the backend (admin) you can find it here. This way you should be able to create rewrites. Also if you want to automate the creation of rewrites you can refer to the core_rewrites table in magento's database. Also this is a good read if you want to do logic based rewrites on the fly.

Redirect for wordpress permalink

I'm trying to change the WordPress permalink structure in .htaccess from /%postname%/ to /%category%/%postname%/ any suggestions?
Yup ditto what Prix said. The WordPress permalink structure rewriting is done internally with php code. Rewriting is done in the root .htaccess file, but permalink structures are handled internally by WordPress. When you save WordPress Permalinks an .htaccess file will be automatically created in your website root folder. The internal Permalink structure rewriting done by WordPress relies on this root .htaccess file in order to correctly perform rewriting.
Permalink Structure Tags are not used in .htaccess code or files and are an internal rewriting feature of WordPress. Or in other words, simply that Permalink Structure Tags are not used in .htaccess code or files.
Try this
http://yoast.com/change-wordpress-permalink-structure/
Look for the orange "generator" button, it does the job for you.
If i'm not wrong, inside the settings on the "permalink" voice you can modify this last one.
Just remember to put the correct .htaccess inside your website:
https://codex.wordpress.org/htaccess
Usually to use correctly the permalink you have to use %postname% on the personalized structure.

Resources