How To Enable Mod_Rewrite For Apache Spider Web Server

I've installed 2 Content Management Systems on my Debian wheezy organization - WordPress in addition to Drupal. The spider web server deployed is the venerable Apache. Common to the 2 deployments is the number of how to enable the mod_rewrite module for the Apache spider web server.

The rewrite module maps obscure URLs - figurer gibberish - to 'clean' URLs. The default URLs, for both WordPress in addition to Drupal, are something similar http://localhost/wordpress/?p=248.

You tin configure the URLs to endure rewritten to resemble the ship service titles: http://localhost/wordpress/a-board-game/. However, the alter won't accept consequence unless the mod_rewrite module is enabled.

Query module status

To banking enterprise tally if mod_rewrite is currently enabled:

  1. Create a PHP script to listing the enabled Apache modules, in addition to house it inwards the Document Root directory (by default: /var/www):
     $ truthful cat > /var/www/testmod.php <?php print_r(apache_get_modules()); ?> 
  2. Run the script past times entering http://localhost/testmod.php into a browser.

If the mod_rewrite module is enabled, yous volition observe it inwards the output of the PHP script.

Enable rewrite

To enable:

  1. Enable mod_rewrite module.
     $ sudo a2enmod rewrite Enabling module rewrite. To activate the novel configuration, yous ask to run:   service apache2 restart 
  2. Set AllowOverride to All inwards Apache configuration files.

    Apache configuration files incorporate directives to command spider web server behavior. The configuration directive we're interested inwards is AllowOverride. For Debian wheezy, expect for the directive inwards /etc/apache2/sites-available/default.

     $ to a greater extent than /etc/apache2/sites-available/default     ..snipped..  <?Directory /var/www/>   Options Indexes FollowSymLinks MultiViews   AllowOverride None   Order allow,deny   permit from all  <?/Directory>     ..snipped.. 

    When the AllowOverride directive is laid upwardly to None for a directory, in addition to then Apache ignores all .htaccess files inwards that directory in addition to inwards its sub-directories.

    The .htaccess files are 'directory-level' Apache configuration files. Web applications such every bit WordPress in addition to Drupal induce got a .htaccess file inwards their respective spider web directories.

    In the to a higher house example, AllowOverride is laid upwardly to None for /var/www, the Document Root directory. Therefore, all .htaccess files are ignored inwards the entire spider web hierarchy.

    Modify AllowOverride to induce got value All.

      <?Directory /var/www/>   Options Indexes FollowSymLinks MultiViews   AllowOverride All   Order allow,deny   permit from all  <?/Directory> 
  3. Restart Apache.
     $ sudo service apache2 restart [ ok ] Restarting spider web server: apache2 ... waiting . 

Disable rewrite

To disable:

 $ sudo a2dismod rewrite Module rewrite disabled. To activate the novel configuration, yous ask to run:   service apache2 restart $ service apache2 restart [ ok ] Restarting spider web server: apache2 ... waiting . 

Berlangganan update artikel terbaru via email:

0 Response to "How To Enable Mod_Rewrite For Apache Spider Web Server"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel