• X

    How to Create WordPress .Htaccess File

    By in WordPress

    Bluehost hosting

    WordPress being a self hosted Blog, you get the flexibility to play with root folder. Today I’m going to talk about WordPress .htaccess file which is an important file for many reasons. You can set many security settings using Wp .htaccess file, add rules for redirection, block bots, secure your blog from spammers and many more. WordPress htaccess File How to Create WordPress .Htaccess FileThough, many Wp users who are hosting their own blog are still not aware of .htaccess file and how to create .htaccess file in WordPress. Today, we will learn many aspect of WordPress .htaccess file and in future tutorials, I will share some useful codes which you can add to keep your blog secure.

    What is WordPress .htaccess file:

    .Htaccess file is not only associated with WordPress, but any Apache webhosting offers .htaccess file feature. When you install WordPress, in most of the cases it comes by default but stay in hidden mode at the root of your WordPress installation. Some time, .htaccess file is not present, and you have to manually create .htaccess file in WordPress. We can use a normal text editor to update or remove the content of our Wp blog .htaccess file. This is default code for your WordPress htaccess file:

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

    # END WordPress

    Here is a question asked by one of ShoutMeLoud reader Kashish: Hi, I want to edit my Permalink to /%postname? in WordPress and it’s showing now to add some code in my .htaccess.txt file, but I could not find it anywhere in my dashboard or root directory. How do I create WordPress .htaccessfile and add the code into it?

    How to create WordPress Htaccess file?

    In most of wordpress blog .htaccess file resides by default in the root of wordpress installation. If youhtaccess thumb How to Create WordPress .Htaccess File are using Filezilla FTP client, you can refer to my post on how to edit your .htaccess file. all you need to do is click on force showing hidden file, from the option menu, which is already explained earlier. In case .htaccess file does not exist, simply create a new notepad file (htaccess.txt) and rename it to .htaccess. Make sure, it should not be like .htaccess.txt in any ways. If you using windows you can uncheck the option which says hide extension of known file type. hide extension thumb How to Create WordPress .Htaccess FileOnce you have renamed the file to .htaccess, upload it to the root of wordpress installation and edit your file according to your need. In case you having hard time renaming from htaccess.txt to .htaccess, simple upload the htaccess.txt file and rename it on the server. Do read following .htaccess related articles for WordPress  :

    Default permission for security of .htaccess file is 644 but at times when you are changing permalink and WP is unable to access your .htaccess file, you can change it’s permission to 777 and update it. Though, make sure to change it’s permission to 644, else it would cause security issues.

    Though his question was specifically for changing permalink and for that I will rather suggest Dean permalink migration plugin and if you like to read about it read : How to use Dean permalink migration plugin. Do let us know if you have any queries regarding WordPress htaccess file, and I would love to answer your query. Don’t forget to subscribe to my Email newsletter for more Wp tips.

    Subscribe to Download WordPress Guide Worth $99

    Discover more awesome articles

    Article by

    Harsh has written 1124 articles.

    If you like This post, you can follow ShoutMeLoud on Twitter. Subscribe to Blogging tips via RSS or EMAIL to receive instant updates.

    { 7 comments… read them below or add one }

    Ajay

    Wasn’t aware about .htaccess, thanks for explaining Harsh. Only if you could write one more article for explaining what all these permissions are.
    Regards.

    Reply

    rahul

    hii..harsh watz up..I have one doubt..in wordpress SEO by Yoast, contains htaccess file..is any thing need to edit..?..I never created one myself…is any thing worry about it??

    Reply

    Harsh Agrawal

    @Rahul
    No, you don’t have to do anything. Basically that plugin lets you edit your .htaccess file directly from WordPress dashboard.

    Reply

    Henry

    Hi Harsh
    Thanks for the useful info!

    My webhosting company has created a database for me and ftp access for our subdomain. After I have installed WP in the root-folder of the subdomain on their server I am getting the 505 internal server error. They said this is usually to do with either the .htaccess file not being in place and using SEO friendly urls. So I have created the .htaccess file using your default code from this blog but I still cant install WP
    Do you know what causing this error?

    My support is very slow, I am hoping earlier answer here.

    Henry

    Reply

    Colorjaws

    Hello, when I put the .htacss file I have an error, I loose all the access to my Wordpress. Any idea why? I am using the wp 3.8.1 thank you

    Reply

    Harsh Agrawal

    @Colorjaws
    This usually happens due to wrong syntax in .htaccess file..

    Reply

    Ankur Agrawal

    Hello Harsh sir, Another useful post. I checked my wordpress root directory for .htaccess file but there wasn’t any so I made one using notepad as described above and renamed it to .htaccess on the server.
    Now my question is there is nothing in my .htaccess file and I have gone through one of your post ” How to edit .htaccess file”. In that it was written ‘ Make sure that permission of your .htaccess file is 644 and not 777′ .
    So what should I do with my .htaccess file because it is blank.
    Please help . Thank you….

    Reply

    Leave a Comment

    Previous post:

    Next post:

    `