How to enable mod_rewrite on Apache 2.4?

こ雲淡風輕ζ 提交于 2019-12-03 12:16:07
Jonathan Solorzano

I found the way to know if a module is loaded or not, here's to command to list the modules enabled:

apachectl -M | sort

It will list all enabled modules alphabetically.

Wordpress has an .htaccess but default where it enables rewrite_module for its use:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

The only thing that i had to do was add this to the vhost.conf file at /etc/httpd/conf.d/vhosts.conf

<Directory /var/www/mysite>
    Options Indexes FollowSymLinks
    Require all granted
    AllowOverride All
</Directory>

That's because I'm handling my hosts in that file. But it could be done at httpd.conf, or any other .conf file that is Included to the httpd.conf

Thanks...

Apache2 ships with executables a2enmod and a2dismod that will do all the "dirty work" of symlinking conf files.

On Debian based distros, the usual location is /etc/apache/mods-available/. Here are the .conf configuration files (when applicable) and a .load file per module with the LoadModule Apache2 directive. A module is enabled if there is a symlink to its .load file in the /etc/apache2/mods-enabled/.

You would, for example, enable the Rewrite module with command

$ a2enmod rewrite
reimi
# nano /etc/httpd/conf/httpd.conf

find

follow (AllowOverride none) 

and change it

(AllowOverride All) 

In httpd.conf, search for AllowOverride None and change it to AllowOverride All, then restart apache

for rewrite module just check this youtube step by step tutorial related to enable rewrite module in wamp apache https://youtu.be/xIspOX9FuVU?t=1m43s
Wamp server icon -> Apache -> Apache Modules and mark as check the rewrite module option
after that you can able to use url rewriting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!