How to enable mod_rewrite for Apache 2.2

后端 未结 15 1363
渐次进展
渐次进展 2020-11-21 07:09

I\'ve got fresh install of Apache 2.2 on my Vista machine, everything works fine, except mod rewrite.

I\'ve uncommented

LoadModule rewrite_module mo         


        
相关标签:
15条回答
  • 2020-11-21 07:12

    Try setting: AllowOverride All.


    Second most common issue is not having mod rewrite enabled: a2enmod rewrite and then restart apache.

    0 讨论(0)
  • 2020-11-21 07:14

    For my situation, I had

    RewriteEngine On
    

    in my .htaccess, along with the module being loaded, and it was not working.

    The solution to my problem was to edit my vhost entry to inlcude

    AllowOverride all
    

    in the <Directory> section for the site in question.

    0 讨论(0)
  • 2020-11-21 07:14

    Use below command

    sudo a2enmod rewrite
    

    And the restart apache through below command

    sudo service apache2 restart
    
    0 讨论(0)
  • 2020-11-21 07:16

    The first time I struggled with mod_rewrite rules ignoring my traffic, I learned (frustratingly) that I had placed them in the wrong <VirtualHost>, which meant that my traffic would ignore all of them no matter how well-written they were. Make sure this isn't happening to you:

    # Change the log location to suit your system. RewriteLog /var/log/apache-rw.log RewriteLogLevel 2

    These parameters will activate if you perform a graceful restart of Apache, so you can recycle them in and closely monitor the mod_rewrite behavior. Once your problem is fixed, turn the RewriteLogLevel back down and celebrate.

    In 100% of my experience, I've found that the RewriteLog has helped me discover the problem with my rewrite rules. I can't recommend this enough. Good luck in your troubleshooting!

    Also, this bookmark is your best friend: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritelog

    0 讨论(0)
  • 2020-11-21 07:18

    <edit>

    Just noticed you said mod_rewrite.s instead of mod_rewrite.so - hope that's a typo in your question and not in the httpd.conf file! :)

    </edit>

    I'm more used to using Apache on Linux, but I had to do this the other day.

    First off, take a look in your Apache install directory. (I'll be assuming you installed it to "C:\Program Files" here)

    Take a look in the folder: "C:\Program Files\Apache Software Foundation\Apache2.2\modules" and make sure that there's a file called mod_rewrite.so in there. (It should be, it's provided as part of the default install.

    Next, open up "C:\Program Files\Apache Software Foundation\Apache2.2\conf" and open httpd.conf. Make sure the line:

    #LoadModule rewrite_module modules/mod_rewrite.so
    

    is uncommented:

    LoadModule rewrite_module modules/mod_rewrite.so
    

    Also, if you want to enable the RewriteEngine by default, you might want to add something like

    <IfModule mod_rewrite>
        RewriteEngine On
    </IfModule>
    

    to the end of your httpd.conf file.

    If not, make sure you specify

    RewriteEngine On
    

    somewhere in your .htaccess file.

    0 讨论(0)
  • 2020-11-21 07:20

    New apache version has change in some way. If your apache version is 2.4 then you have to go to /etc/apache2/. There will be a file named apache2.conf. You have to edit that one(you should have root permission). Change directory text like this

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

    Now restart apache.

    service apache2 reload
    

    Hope it works.

    0 讨论(0)
提交回复
热议问题