I have installed rewrite_module and modified php.ini
on Apache.
I create rewrite.php
and .htaccess
files, but it\'s not working.
To get mod_rewrite to work for me in Apache 2.4, I had to add the "Require all granted" line below.
<Directory /var/www>
# Required if running apache > 2.4
Require all granted
RewriteEngine on
RewriteRule ^cachebust-([a-z0-9]+)\/(.*) /$2 [L]
</Directory>
supposedly a similar requirement exists for Apache 2.2 as well, if you're using that:
<Directory /var/www>
# Required if running apache 2.2
Order allow,deny
Allow from all
RewriteEngine on
RewriteRule ^cachebust-([a-z0-9]+)\/(.*) /$2 [L]
</Directory>
Note that an ErrorDocument 404
directive can sometimes override these things as well, so if it's not working try commenting out your ErrorDocument directive and see if it works. The above example can be used to ensure a site isn't served from cache by including a subfolder in the path, though the files reside at the root of the server.
Try setting: "AllowOverride All".
Please try
sudo a2enmod rewrite
or use correct apache restart command
sudo /etc/init.d/apache2 restart
On centOS7 I changed the file /etc/httpd/conf/httpd.conf
from AllowOverride None to AllowOverride All
It's working.
my solution is:
1.create a test.conf into /etc/httpd/conf.d/test.conf
2.wrote some rule, like:
<Directory "/var/www/html/test">
RewriteEngine On
RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L]
</Directory>
3.restart your Apache server.
4.try again yourself.