How To Set Up Mod_Rewrite
How To Set Up Mod_Rewrite
If you are looking to manage your website's URLs and improve its SEO, Mod_Rewrite is a powerful tool that can help. Here's how to set it up:
- Make sure you have Apache installed on your server. If you don't, install it.
- Enable the Mod_Rewrite module in Apache by adding the following line to your httpd.conf file:
LoadModule rewrite_module modules/mod_rewrite.so - Create a .htaccess file in the root directory of your website (if you don't already have one).
- Inside the .htaccess file, add the following code:
This code redirects any requests for "old-page" to "new-page". You can replace "old-page" and "new-page" with the URLs you want to redirect.RewriteEngine On RewriteRule ^old-page$ /new-page [R=301,L] - Save the .htaccess file.
- Test the redirection by accessing the "old-page" URL in your web browser. You should be automatically redirected to the "new-page" URL.
Mod_Rewrite can do much more than simple URL redirection. With it, you can create SEO-friendly URLs, block access to certain pages, and more. Check out the official Apache documentation for more information.
Keywords: Mod_Rewrite, Apache, URL management, SEO, .htaccess, httpd.conf.
Комментарии
Отправить комментарий