linux under apache opens url override method of

  • 2020-05-06 12:03:09
  • OfStack

Linux opens the url override method:

Open httpd.conf (usually in the /etc/httpd/conf directory)

2. Find #LoadModule rewrite_module modules/ mod_rewrite. so remove #
from the front
3. Find AllowOverride None and change it to AllowOverride All
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 site. There would be no effect without this file, or if this document did not define any rules for URL rewrite.

Restart apache (with command: service httpd restart).

Apache open URL rewrite function method
1, about the rewrite module call:
The URL rewrite in Apache 2.x is implemented by mod_rewrite.so, so you need to see if your Apache has been compiled into the module and has been called in httpd.conf in Apache's configuration file httpd.conf. In most major releases, Apache 2.x has the rewrite module incorporated. Let's say I use Slackware. The configuration file for Apache 2.x is located in the /etc/httpd directory.

In httpd.conf, we will find a line similar to the following for the rewrite module, whose name is mod_rewrite.so.

LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
Or
LoadModule rewrite_module lib apache2 / modules/mod_rewrite so if there # # before, do you want to get rid of. For most distributions, Apache 2 modules are typically located in the following two locations,

/usr/lib/apache2/modules

Or
/ usr/lib/httpd/modules if open calls in httpd rewrite_module Settings, check whether can call, through the httpd - M parameters to view;

#/usr/sbin/httpd -M

If the following line is found, the module can be called

rewrite_module (shared)

2. Set Directory of DocumentRoot:


In Apache 2.x, we will see a row for the DocumentRoot setting. This is where the web applications are stored. For example, LinuxSir.Org is in the /opt/www directory. So we're going to set DocumentRoot as follows.

DocumentRoot "/opt/www" and then we're going to do some behavior Settings for DocumentRoot. In general, httpd.conf will give you a default. If you want to change the path of DocumentRoot, you also want to change the Settings of Directory for DocumentRoot, which is

< Directory "path set by DocumentRoot ">

For example, if we change the path of DocumentRoot to "/opt/www", we also need to change the path of Directory to "/opt/www".

< Directory "/opt/www" >

Options FollowSymLinks
Note: put a # in front of this line and then the bottom line, AllowOverride ALL
AllowOverride ALL
Order allow,deny
Allow from all
< /Directory > We set the AllowOverride parameter to ALL, which means that the URL rule rewrite is supported on the entire server. The Apache server reads the.htaccess file at the root of each site. If you do not have this file, or if the document does not define any rules for URL overrides, there will be no effect. In general, mature Web server application suites support URL overrides, such as drupal and joomla. When we use these programs, we will find this file in the.htaccess installation package. Once we've configured Apache, we just need to turn it on in the background of these programs.

3. Restart httpd server:

In general, there are httpd server startup scripts, such as
, in each distribution # / 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

Related articles: