How to create .htaccess file and update it

#881566
Viewing 11 replies - 1 through 11 (of 11 total)
  • Hello,

    We apologize for the issue you are facing with creating and updating the .htaccess file. Thank you for sharing the screenshots; they can be very helpful in diagnosing the problem.

    To create a .htaccess file, you can follow these steps:

    Using FTP:

    1. Access your website files using FTP.
    2. Navigate to the root directory of your website.
    3. Right-click and select Create new file.
    4. Name the file .htaccess and click OK.
      Create htaccess file in FTP

    Using cPanel File Manager:

    1. Log in to your cPanel account.
    2. Go to File Manager and navigate to the root directory of your website.
    3. Click on the + File button at the top-left corner.
    4. Enter the name .htaccess and click Create New File.
      Create htaccess file in cPanel File Manager

    Updating the .htaccess File:

    1. Once the .htaccess file is created, go to Rank Math SEO โ†’ General Settings โ†’ Edit .htaccess in your WordPress dashboard.
      Edit .htaccess in Rank Math
    2. If you see a message that says .htaccess file is not writable, you may need to add a filter to allow editing:
      /**
      * Allow editing the robots.txt & htaccess data.
      *
      * @param bool Can edit the robots & htacess data.
      */
      add_filter( 'rank_math/can_edit_file', '__return_true' );
    3. After making your changes, click Save Changes.

    If you continue to experience issues, please reply to this ticket with more details about what happens when you try to create or update the .htaccess file, and a human agent from the Rank Math Support team will assist you further.

    Thank you for your patience!

    Sources:
    How to Edit Your htaccess File Using Rank Math ยป Rank Math

    Hello,

    If the issue persists after following the steps above, please follow the steps in this guide:
    https://rankmath.com/kb/cant-edit-robots-txt/#not-writeable

    Looking forward to helping you.

    Thank you, I’ll give it a try! Also, I just to mention it in advance as I’m not sure if it affects it. I’m still using wpcomstaging website before moving to the new URL. Would that affect it? I heard it affects indexing so I thought it would be worth mentioning as I’m not sure if it would be the issue. Otherwise, I’ll follow the steps. Thanks!

    This is the link: https://kingscourtgalleriesuk.wpcomstaging.com/

    Hello,

    Sure, let us know how this goes.

    If you’re using the staging, you may need to ensure that the .htaccess file is found on the root directory of that site.

    Looking forward to helping you.

    Hi, thanks for your advice! However, it seems like I’m still doing something wrong. Can you please advise me on what it might be? ๐Ÿ™ Thank you.

    https://snipboard.io/J5KTqh.jpg
    https://snipboard.io/cJN1R3.jpg
    https://snipboard.io/kHtuiI.jpg

    Hello,

    The code in your screenshot here is incorrectly applied.

    Please follow the steps in this guide to properly apply it:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Looking forward to helping you.

    Hello @trailblazeddigital,

    If you still need help with this, please let us know.

    Regards,

    Hello, I apologise for a late reply as I was away for a few days. I tried to apply the code to the child theme but it doesn’t seem to work. May I please ask you what am I doing wrong? Thank you. ๐Ÿ™‚

    https://snipboard.io/1KRWNt.jpg
    https://snipboard.io/r6SZ2Y.jpg

    Hello,

    Your site is using Nginx server and it doesn’t use .htaccess file. That’s why your site doesn’t have a default .htaccess file and there is no point in creating it. If you want to add some rules, you should get in touch with your host and ask them to add those in your site’s server configuration file.

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Hi Jaideep,
    Haha, that explains it! Thanks for letting me know I wish I knew earlier. That makes sense and appreciate it. Have a great day! ๐Ÿ™‚

    Hello,

    We are super happy that this resolved your issue.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 11 replies - 1 through 11 (of 11 total)

The ticket ‘How to create .htaccess file and update it’ is closed to new replies.