How to create a .htaccess file?

Please visit our channel & subscribe: https://youtube.com/dhakawebhost
 
Depending on your install, you may not have an .htaccess file so before you can think about editing it, you may need to create one. You can either use your favorite text editor to create one or do it directly in cPanel.When you’re creating a new .htaccess file, it’s important that you set a file permission of 644 to protect it from potential attacks.

Create and upload a new file and name it .htaccess, or click the File button at the top left of the File Manager in cPanel to create a blank file named .htaccess.

If your server doesn’t allow you to do this, create a file called htaccess.txt instead, then rename the file to .htaccess once it’s uploaded to your site.

Since all WordPress installs have pretty permalinks set by default since version 4.2, it’s best to side on the err of caution and include the code that’s default for .htaccess files in the newer versions of WordPress instead of creating a blank file.
Here’s the default code you should include for single installs of WordPress:

            # 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
            
For Multisite networks installed with sub-directories using version 3.5 or higher, use the following code instead:

            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]
    
If your Multisite is installed with sub-domains and the version you’re using is 3.5 or higher, use the code below instead of the options above:

            RewriteEngine On
            RewriteBase /
            RewriteRule ^index\.php$ - [L]
            # add a trailing slash to /wp-admin
            RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
            RewriteCond %{REQUEST_FILENAME} -f [OR]
            RewriteCond %{REQUEST_FILENAME} -d
            RewriteRule ^ - [L]
            RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
            RewriteRule ^(.*\.php)$ $1 [L]
            RewriteRule . index.php [L]
  • 1 brukere syntes dette svaret var til hjelp
Var dette svaret til hjelp?

Relaterte artikler

.htaccess in WordPress

Please visit our channel & subscribe: https://youtube.com/dhakawebhost   The .htaccess file...

Where the .htaccess file located and what's .htaccess got to do with It?

Please visit our channel & subscribe: https://youtube.com/dhakawebhost   The...

How to download .htaccess file?

Please visit our channel & subscribe: https://youtube.com/dhakawebhost   You can download a...

Where to Add Your Changes?

Please visit our channel & subscribe: https://youtube.com/dhakawebhost   When you’re...

How to Edit Your .htaccess File?

Please visit our channel & subscribe: https://youtube.com/dhakawebhost   There are many...