Changing Permalinks - wordpress

I want to change my permalinks from /%year%/%monthnum%/%day%/%postname%/ to /%postname%/
but when I added the following to the .htaccess file, posts didn't redirect the way I thought they would:
RedirectMatch 301 /dddd/dd/dd/(.*) /$1
What do I need to put into my .htaccess file to make it work?
My site is http://SweatingTheBigStuff.com

I think everyone is missing the point here - I think #Daniel has changed his permalinks, and now wants to redirect old permalinks.
The problem is your RedirectMatch regex is only matching a literal 'd', not digits.
Personally I would use this instead;
RedirectMatch 301 ^/[0-9]{4}/[0-9]{2}/[0-9]{2}/(.+)$ /$1
However, #markratledge is right in saying that there are issues with using just the postname.

You don't go into any code to change permalinks; that's changing WP core files, you'll break things and you'll loose your changes on an upgrade. It's much easier than that: go to Wordpress/Dashboard/Setings/Permalinks. If your .htaccess isn't writable, you'll get a warning.
And, using only the postname in permalinks is not recommended for performance reasons: Using only Postname in Permalinks « WordPress Codex

A relevant answer to TheDeadMedic,
You could use a plugin called Redirection to redirected your old permalinks to new permalinks.
But if you need to change your permalinks from the old version to a new version, then follow markratledge's advice

Related

Redirect 404 from sub-folder

I need/want to redirect 404 from a specific sub-folder to another page. I am using WordPress. I suspect this would likely be done using .htaccess. I am really struggling with the code. For example...
I would like www.mydomain.com/knowledge-base/url-does-not-exist/ to redirect to www.mydomain.com/knowledge-base/.
Any 404 that is not associated with the sub-folder "knowledge-base" should use the default 404 page set out in WordPress.
I should note that the sub-folder "knowledge-bsae" doesn't actually exist - it is virtual.
Can someone help me with the code?
you could try to insert RewriteRule ^subdirectory/(.*)$ /anotherdirectory/$1 [R=301,NC,L] to .htaccess , make sure there's RewriteEngine On, and paste the code below it.
this reference might help you redirect directory to another
301 is permanent and 302 is temporary for redirect.
another option is, ( i haven't tried this yet ) but you could add another .htaccess file to your subfolder, then ErrorDocument 404 /path/to/yourcustompage .
good luck

.htaccess rewrite domain.com/en/multisite to domain.com/multisite/en

I'm using multisite WordPress and qTranslateX plugin. My default website is in Bahasa and my second language is English. When I use custom link in mode language English like mydomain.com/multisite, it always added by "en" after mydomain.com, it will be mydomain.com/en/multisite. That link always return 404 because there is no page.
I want to use .htaccess to rewrite URL form mydomain.com/en/multisite to mydomain.com/multisite/en .
Thanks in advance
Unfortunately, you can't achieve that with mod_rewrite alone as far as I know.
Wordpress will look at the REQUEST_URI to figure out what to show, and that one won't be overwritten (and [E=REQUEST_URI:...] will make it $_SERVER["REDIRECT_REDIRECT_REQUEST_URI"]).
If mod_proxy is installed as well, you could do something like this:
RewriteEngine On
RewriteBase /
RewriteRule ^en/([^/]+)(/?.*)$ /$1/en$2 [P,L]
It will proxy the request internally on the same host and server.
Requesting http://example.org/en/test will look to wordpress as if http://example.org/test/en was requested.
Give it a try. If mod_proxy isn't installed, it won't work (and render a 404 for the URL), but it won't break your site, so it's pretty safe to experiment with.

Wordpress .htaccess rewrite

I have wordpress installed. I want to customize permalink as following:
Category: http://my-domain/{category-name}/
Post: http://my-domain/{category-name}/{postname}/
Post with params: http://my-domain/{category-name}/{postname}/{param1}/
Post with params: http://my-domain/{category-name}/{postname}/{param1}/{param2}/
Can I do only use .htaccess?
Thanks!
P.S: Sorry for my bad English.
In the admin dashboard, customize the permanent links to
http://my-domain/%category%/%postname%/
In Wordpress you can do this through backend. Go to Settings-->Permalinks-->Custom Structure and insert:
%category%/%postname%
You can refer here
If you wish to use other subfolders you need to create .htaccess file (if you are using Apache) in your root folder and use url rewrite like this:
RedirectMatch 301 /old-directory/(.*) /new-directory/
Be sure mod_rewrite Apache module is enabled.

Redirect Wordpress Permalink in htaccess

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/

Convert these rewrite apache rules to nginx

In my Wordpress, I changed the posts permalinks structure. In order to don't get 404 erros for the old links, I would like to redirect the old permalinks to the new permalinks. According to this, the following code must be added in my .htacess so that I can get the redirect working from old posts links to the new posts link:
RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([^/]+).html$ http://myurl.com/$3
That's good, however, I don't use Apache – I use nginx. How can I convert this rules to nginx? I've already tried a apache to nginx online converter, with no success.
Thanks!
I believe this is what you want. "permanent" is 301 according to this page.
rewrite "^/([0-9]{4})/([0-9]{2})/([^/]+).html$" http://myurl.com/$3 permanent;

Resources