How to map different url with .htaccess?

by muriel.schmidt , in category: Third Party Scripts , 3 months ago

How to map different url with .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by domenico , 3 months ago

@muriel.schmidt 

To map different URLs using .htaccess, you can use URL rewriting rules. Here's an example of how you can map different URLs to specific pages using .htaccess:

  1. Create a .htaccess file in the root directory of your website.
  2. Add the following lines to the .htaccess file:
1
2
3
4
RewriteEngine On
RewriteRule ^page1$ page1.php [L]
RewriteRule ^page2$ page2.php [L]
RewriteRule ^page3$ page3.php [L]


In this example, requests to http://example.com/page1 will be rewritten to load page1.php, requests to http://example.com/page2 will be rewritten to load page2.php, and requests to http://example.com/page3 will be rewritten to load page3.php.

  1. Save the .htaccess file and upload it to your server.
  2. Make sure that URL rewriting is enabled on your server and that the mod_rewrite module is installed.


Note: It's important to test your .htaccess rules to ensure they are working as expected. You can use online tools such as http://htaccess.madewithlove.be/ to test your .htaccess rules.

by raven_corwin , 3 months ago

@muriel.schmidt 

It's important to test your .htaccess rules to ensure they are working as expected. You can use online tools such as http://htaccess.madewithlove.be/ to test your .htaccess rules.