I’m using WordPress and wanted to enable pretty urls feature, but they don’t work, i’m thinking that it’s because of mod_rewrite, but i don’t know how to enable it on Apache 2.4 under CentOS 7…
I’ve already try this:
grep -i LoadModule /etc/httpd/conf/httpd.conf | grep rewrite
but nothing…
Also would like to know it loading all Apache modules has any bad consequence or is it bad practice?
I found the way to know if a module is loaded or not, here’s to command to list the modules enabled:
It will list all enabled modules alphabetically.
WordPress has an .htaccess but default where it enables
rewrite_module
for its use:The only thing that i had to do was add this to the vhost.conf file at
/etc/httpd/conf.d/vhosts.conf
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 thehttpd.conf
Thanks…
Apache2 ships with executables
a2enmod
anda2dismod
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 theLoadModule
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
find
and change it
In httpd.conf, search for AllowOverride None and change it to AllowOverride All, then restart apache
Yes, changing from “Override None” to “Override All” made it work:
On Debian 10 config file is here:
/etc/apache2/apache2.conf
I don’t know the security risks, but it works!
For CentO 7 Only :
a2enmod is a Debian/Ubuntu command. You’ll need to edit the Apache config file for a CentOS server.
What you’d want to do is edit the /etc/httpd/conf/httpd.conf file and make sure that the AllowOverride flag for the block is changed from None to All.
Basically it should be something like this:
(Note: there are many comment lines in the default httpd.conf file)
<Directory “/var/www/html”>
AllowOverride All
</Directory>
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