Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

URL-rewriting can be achieved using the mod-rewrite module in .htaccess by creating rewrite rules that redirect incoming URLs to new URLs or modify the appearance of existing URLs.

To enable mod-rewrite and create rewrite rules, follow these steps:

  1. Enable the mod-rewrite module by adding the following line to your .htaccess file at the beginning:

    RewriteEngine On

  2. Define the rewrite rules that apply to your URLs. A basic example of a rewrite rule is:

    RewriteRule ^old-url$ /new-url [R,L]

    This rule redirects requests for the "old-url" to the "new-url".

  3. Save the .htaccess file and upload it to your server.

  4. Test the rewrite rules by accessing the affected URLs and verifying that the redirection or modification occurs as expected.

Additional rewrite rule options and syntax can be found in Apache's official documentation: https://httpd.apache.org/docs/current/mod/mod_rewrite.html