Ask Your Question
0

How can URL-rewriting be achieved using mod-rewrite in .htaccess?

asked 2021-12-12 11:00:00 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2021-04-16 06:00:00 +0000

lalupa gravatar image

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/m…

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-12-12 11:00:00 +0000

Seen: 17 times

Last updated: Apr 16 '21