How to rewrite single url using .htaccess?


by arlo , in category: SEO , 7 months ago

How to rewrite single url using .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

by chasity.halvorson , 7 months ago


To rewrite a single URL using .htaccess, you can use the RewriteRule directive. Here's how you can do it:

  1. Create or edit an .htaccess file in the root directory of your website.
  2. Add the following line to the .htaccess file: RewriteEngine On
  3. Specify the URL pattern you want to rewrite using the RewriteRule directive. For example, let's say you want to rewrite the URL "" to "". You would use the following line: RewriteRule ^old-page$ new-page [L] This line matches the URL pattern "^old-page$" (means exact match for "old-page") and redirects it to "new-page". The [L] flag indicates that this is the last rule to process if the pattern is matched.
  4. Save the .htaccess file and upload it to your website's root directory.

Now, when someone visits "", they will be automatically redirected to "".