BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl
Home / WordPress / How to create .htaccess file in WordPress

How to create .htaccess file in WordPress

By Chaitanya Singh

In the last post, we discussed how to edit .htaccess file. In this post I’m going to cover how you can create this file. If you have installed WordPress on your blog then you would be having a default .htaccess file having below content –

[code]

# BEGIN WordPress
RewriteRule ^index.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress [/code]

How to create it?

How to create .htaccess file in WordPress

In case you don’t have this file then you can simply create a htaccess.txt file (You may face some difficulties while creating a file named .htaccess as Windows may prevent this to happen) and copy the above content. Upload the file to server and rename it to .htaccess from htaccess.txt.

What should be the ideal file permissions for .htaccess after creation?

Do not compromise with the security of this file as this is one of the sensitive file and if you don’t prevent it viewing by others then it may cause several security issues.

The permissions should be: 644 (RW-R–R–)

In order to change the permissions login to cpanel. Refer the screenshots –

» Right click on the file and click on “change permissions”.
.htaccess-change-permissions

» Change it to 644 as shown below –
htaccess

You can do several things with this file, if you handle it properly. I’ll share more about it in upcoming posts. That’s all for now. Happy reading!!

Posted Under: WordPress

Leave a Reply Cancel reply

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

Copyright © 2012 – 2022 BeginnersBook . Privacy Policy . Sitemap