Proudly Hosting over 100,000 Fast Websites since 2010

How can we help you?

Type your topic or keywords and hit enter to search our knowledgebase.

How to Create a User-friendly URL Using htaccess

Creating user-friendly URLs is crucial for improving the usability and SEO of your website. You can achieve this by using .htaccess file rules to rewrite URLs. Here’s a detailed guide on how to create user-friendly URLs using .htaccess for Host4Geeks users:

Step-by-Step Guide to Creating a User-Friendly URL Using .htaccess

1. Log into cPanel

  • Access cPanel

Open your web browser and navigate to the cPanel login URL provided by Host4Geeks. This is typically something like or

  • Login Credentials

Enter your cPanel username and password to log in.

2. Navigate to the File Manager

  • File Manager

Once you are logged into cPanel, scroll down to the “Files” section.

  • Open File Manager

Click on the “File Manager” icon to open it. This will allow you to manage your website files.

3. Locate the .htaccess File

  • Document Root

In the File Manager, navigate to the root directory of your website. This is usually the public_html directory for your main domain or a subdirectory for addon domains or subdomains.

  • Show Hidden Files

Ensure that you can see hidden files by clicking on “Settings” in the top-right corner of the File Manager and checking the “Show Hidden Files (dotfiles)” option.

  • Find .htaccess

Look for the .htaccess file in your root directory. If it doesn’t exist, you can create one.

4. Edit the .htaccess File

  • Edit Option

Right-click on the .htaccess file and select “Edit” from the context menu. A text editor will open within cPanel.

5. Add URL Rewrite Rules

  • Basic Rewrite Rule

To create a user-friendly URL, you need to add a rewrite rule to your .htaccess file. Here’s an example of a basic rewrite rule:

RewriteEngine On 

RewriteRule ^user-friendly-url$ /original-file.php [L] 

  • Explanation:
  • RewriteEngine On

Enables the rewrite engine.

  • RewriteRule ^user-friendly-url$ /original-file.php [L]: This rule tells the server to serve original-file.php when a user accesses The ^ indicates the start of the URL, and the $ indicates the end of the URL. The [L] flag means “Last” and tells the server to stop processing other rules if this one matches.

6. Advanced Rewrite Rules

  • Parameters in URL: If you want to pass parameters through the URL, you can use a more complex rule. For example:

RewriteEngine On RewriteRule ^product/([0-9]+)$ /product.php?id=$1 [L] 

  • Explanation
    • RewriteRule ^product/([0-9]+)$ /product.php?id=$1 [L]

This rule rewrites URLs of the form to product.php?id=123. The ([0-9]+) part is a regular expression that matches one or more digits, capturing them in a group. $1 refers to the captured group.

7. Save the Changes

  • Save File

After adding the rewrite rules, click the “Save Changes” button in the text editor.

  • Close Editor

Close the editor after saving your changes.

8. Test the URL

  • Testing

Open your web browser and navigate to the user-friendly URL you set up (e.g., It should display the content of the original file specified in the rewrite rule.

  • Error Checking

If the URL does not work as expected, check the .htaccess file for syntax errors and ensure the paths to the files are correct.

Additional Tips for URL Rewriting

  • SEO Considerations: User-friendly URLs are better for SEO. Use meaningful keywords in your URLs to help search engines understand the content of your pages.
  • Consistency: Maintain a consistent URL structure across your website for better user experience and easier management.
  • Testing: Always test your rewrite rules in a development environment before applying them to your live site to avoid downtime or errors.


  • 500 Internal Server Error: If you encounter a 500 error, it often indicates a syntax error in your .htaccess file. Double-check your rules for correctness.
  • No Effect: If your rewrite rules are not having any effect, ensure that mod_rewrite is enabled on your server. You can check with Host4Geeks support if needed.
  • Order of Rules: The order of rules in your .htaccess file matters. Ensure that your specific rules are placed before any broader rules to avoid conflicts.

Contacting Support

For any issues or additional help, you can reach out to Host4Geeks customer support through:

  • Support Portal: Access the support portal from your Host4Geeks account.
  • Live Chat: Use the live chat feature on the Host4Geeks website.
  • Email: Send an email to the Host4Geeks support team.

By following these detailed steps, you can effectively create user-friendly URLs using .htaccess on Host4Geeks, enhancing both the user experience and SEO of your website.

Updated on June 18, 2024