Install and configure mod_rewrite for Apache 2 on Mac OS X for Zend Framework 2

前端 未结 8 913
不思量自难忘°
不思量自难忘° 2020-12-13 09:16

I getting started with zend framework 2 and they have a prerequisite of an installation and configuration of mod_rewrite for apache. Apache 2.2.22 came pre-installed on Mac

相关标签:
8条回答
  • 2020-12-13 09:43

    Add this to http-vhosts.conf file

    <Directory "/Library/WebServer/Documents">
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      Allow from all
    </Directory>
    

    Don't forget to reload your apache using this commande

    sudo apachectl restart
    

    Good luck

    0 讨论(0)
  • 2020-12-13 09:43

    I know this is an old thread, but this also might raise this issue:

    Make sure DocumentRoot and Directory links to the same folder in /etc/apache2/extra/httpd-vhosts.conf as following:

    This is an innocent mistake if you copy the virtual host block from existing sites.

    Cheers!

    0 讨论(0)
  • 2020-12-13 09:52

    If you are serving your site from ~/Sites, the trick for me was modifying my /private/etc/apache2/users/USERNAME.conf file. Initially, the content was:

    <Directory "/Users/USERNAME/Sites/">
        Options Indexes MultiViews FollowSymLinks ExecCGI
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    

    Changing AllowOverride to all and then restarting the server with a quick sudo apachectl restart enabled me to start using mod_rewrite in .htaccess files living beneath ~/Sites.

    0 讨论(0)
  • 2020-12-13 09:52

    yosemite os x should be like this:

    <VirtualHost *:80>
        ServerAdmin enzo@enzolutions.com
        DocumentRoot "/Users/enzo/www/drupal8"
    
        ServerName drupal8
    
        #ServerAlias www.dummy-host.example.com
        <Directory /Users/enzo/www/drupal8>
            Require all granted
            Options Includes FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    
        ErrorLog "/private/var/log/apache2/drupal8-error.log"
        CustomLog "/private/var/log/apache2/drupal8-access.log" common
    </VirtualHost>
    

    gotten from this blog post

    0 讨论(0)
  • 2020-12-13 09:57

    In addition to Rob Allen's response, both line numbers are located around 168 and 169 (to save you some time from scrolling the 500+ lines of text). Also, to explain what each line does exactly:

    LoadModule rewrite_module libexec/apache2/mod_rewrite.so
    

    This overrides the default settings for any .htaccess files used at the document root

    LoadModule php5_module        libexec/apache2/libphp5.so
    

    This allows URL rewrites for permalinks

    Source: link

    0 讨论(0)
  • 2020-12-13 10:02

    My chose

    <VirtualHost *:80>
        <Directory />
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
        ServerAdmin user@domain.ru
        DocumentRoot "/Users/r00we/sites/buytocoins.ru"
        ServerName site.ru
        ServerAlias www.site.ru
        ErrorLog "/private/var/log/apache2/myfaketestsite.com-error_log"
        CustomLog "/private/var/log/apache2/myfaketestsite.com-access_log" common
    </VirtualHost>
    
    0 讨论(0)
提交回复
热议问题