apache mod_rewrite is not working or not enabled

前端 未结 5 1249
后悔当初
后悔当初 2021-02-02 05:56

I have installed rewrite_module and modified php.ini on Apache.

I create rewrite.php and .htaccess files, but it\'s not working.

5条回答
  •  醉酒成梦
    2021-02-02 06:43

    To get mod_rewrite to work for me in Apache 2.4, I had to add the "Require all granted" line below.

    
       # Required if running apache > 2.4
       Require all granted
    
       RewriteEngine on 
       RewriteRule ^cachebust-([a-z0-9]+)\/(.*) /$2 [L] 
     
    

    supposedly a similar requirement exists for Apache 2.2 as well, if you're using that:

    
       # Required if running apache 2.2
       Order allow,deny
       Allow from all
    
       RewriteEngine on 
       RewriteRule ^cachebust-([a-z0-9]+)\/(.*) /$2 [L] 
     
    

    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.

提交回复
热议问题