In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to enable url rewriting in apache under linux". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to turn on url rewriting in apache under linux".
Linux: how to enable url rewriting:
1. Open httpd.conf in apache (usually in / etc/httpd/conf directory)
2. Find # loadmodule rewrite_module modules/mod_rewrite.so and remove the previous #
3. Find allowoverride none and change it to allowoverride all. Two of them will be changed.
Note: the parameter of allowoverride is set to all, which means that url rule rewriting is supported on the entire server. The apache server reads the .htaccess file in the directory under each website. It won't have any effect if it doesn't have this file, or if it doesn't define any rules for url rewriting.
Restart apache (with the command: service httpd restart).
Details of how to enable url rewriting function by apache
1. About the call of rewrite module:
Url rewriting in apache 2.x is implemented through mod_rewrite.so, so you need to check to see if your apache has been compiled into this module, and the module has been called in apache's configuration file httpd.conf. In most major distributions, apache 2.x incorporates the rewrite module. For example, I use slackware. The configuration file for apache 2.x is placed in the / etc/httpd directory.
In httpd.conf, we will find a line similar to the following, which is about the rewrite module, whose name is mod_rewrite.so.
Loadmodule rewrite_module lib/httpd/modules/mod_rewrite.so
Or
If there is a # in front of loadmodule rewrite_module lib/apache2/modules/mod_rewrite.so, you need to remove it. For most distributions, the modules of apache 2 are generally located in the following two locations
/ usr/lib/apache2/modules
Or
/ usr/lib/httpd/modules if you open the setting for calling rewrite_module in httpd, check to see if it can be called. Check it through the parameter httpd-m.
# / usr/sbin/httpd-m
If you find the following line, the module can already be called.
Rewrite_module (shared)
2. Set the directory of documentroot:
In apache 2.x, we will see the line set by documentroot. This line is where web programs are stored. For example, linuxsir.org is stored in the / opt/www directory. Then we need to set the documentroot to the following.
Documentroot "/ opt/www" and then we have to do targeted behavior settings for documentroot. In general, httpd.conf will give a default. If you want to change the path of documentroot, also change the setting of directory for documentroot, that is,
For example, if we change the path of documentroot to "/ opt/www", then we also need to change the specific behavior settings of directory to this path.
Options followsymlinks
# allowoverride none Note: precede this line with a # sign, and then add the following line, which is allowoverride all
Allowoverride all
Order allow,deny
Allow from all
We set the parameter of allowoverride to all, which means that url rule rewriting is supported on the entire server. The apache server reads the .htaccess file in the root directory of each Web site. If you don't have this file, or if it doesn't define any rules for url rewriting, it won't have any effect. In general, mature web server application suites support url rewriting, such as drupal and joomla. When we use these programs, we will find this file in .htaccess in the installation package. After we have configured apache, we just need to turn on this feature in the background of these programs.
3. Restart the httpd server:
In general, there are httpd server startup scripts in each distribution, such as
# / etc/rc.d/rc.httpd restart Note: slackware linux
# / etc/init.d/apache2 restart Note: ubuntu, debian, etc.
# / etc/init.d/httpd start Note: fedora, redhat, centos
Thank you for reading, the above is the content of "how to enable url rewriting in apache under linux". After the study of this article, I believe you have a deeper understanding of how to turn on url rewriting in apache under linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.