WordPress default htaccess

I had to make this entry on the wordpress default htaccess because sometimes, migrating from one server to another, the default .haccess they bring is not usable me for another server and it gives error 500. In this case I see myself forced to look for an htaccess in another WordPress installation. Only to copy and paste the snippet of code that wordpress inserts in it. So I say… why not put it on the page where I write down things?

Remember that the htaccess file is hidden. In case you have problems when creating or modifying it, maybe already exist and you should edit it instead of creating it. Remember, you have to create it in the root directory of your installation and you must use the file manager of your hosting or an FTP client.

Without further instructions here I leave the default htaccess of WordPress, with friendly URLS enabled:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

And although I do not use the WordPress multisite (I think I only used it once in a year), here I include the htaccess of this one too, with its friendly URLs activated.

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

The other way to restore it, if you have access to the wp-admin is by going to Settings -> Permanent links and directly save the settings. If the Apache user has permissions, WordPress will write this same code automatically.

Remember that I am not responsible for any negative results, only YOU are responsible for making your backup in case any problem occurs.

If I have helped you, do not forget to rate me with 5 stars, comment and share!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.