Most Useful .htaccess Tricks for WordPress website

Most Useful .htaccess Tricks for WordPress website

Some most useful .htaccess tricks for your WordPress website are here. Wordpress needs htaccess to work perfectly and runs smoothly.

Here is the htaccess code for a basic wordpress site:

# 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


-----------



If you are using Localhost, for example:
http://localhost/codingsparks

Then htaccess is...

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



Wordpress MultiSite htaccess:

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]


Reference Link: https://codex.wordpress.org/htaccess

Comments

Popular posts from this blog

How To Install XAMPP/LAMPP Stack On Ubuntu 16.04 64bit Step by Step