星期二, 7月 22, 2014

「PHP」Laravel osx 設定 .htaccess

「PHP」Laravel osx 設定 .htaccess


apache config

  1. 設定 vim httpd.conf 的 AllowOverride All
  2. sudo apachectl restart
<VirtualHost *:80>

    DocumentRoot /Library/WebServer/Documents
    <Directory /Library/WebServer/Documents>
        AllowOverride All
        Allow from all
    </Directory>

    RailsEnv development

    Alias /noteBox /Users/cake/Web_www/noteBox/public
    <Directory  /Users/cake/Web_www/noteBox/public>
        #PassengerAppRoot  /home/User/web_ror/home/public
        PassengerAppRoot  /Users/User/Web_www/noteBox
        Allow from all
        Options -MultiViews
        #RailsBaseURI /rails
    </Directory>

</VirtualHost>

Laravel 中 public/.htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
%23%23%23%20%u300CPHP%u300DLaravel%20osx%20%u8A2D%u5B9A%20.htaccess%0A---%0A%0A%23%23%23%23%20apache%20config%0A1.%20%u8A2D%u5B9A%20vim%20httpd.conf%20%u7684%20AllowOverride%20All%0A2.%20sudo%20apachectl%20restart%0A%0A%60%60%60%20conf%0A%3CVirtualHost%20*%3A80%3E%0A%0A%20%20%20%20DocumentRoot%20/Library/WebServer/Documents%0A%20%20%20%20%3CDirectory%20/Library/WebServer/Documents%3E%0A%20%20%20%20%20%20%20%20AllowOverride%20All%0A%20%20%20%20%20%20%20%20Allow%20from%20all%0A%20%20%20%20%3C/Directory%3E%0A%0A%20%20%20%20RailsEnv%20development%0A%0A%20%20%20%20Alias%20/noteBox%20/Users/cake/Web_www/noteBox/public%0A%20%20%20%20%3CDirectory%20%20/Users/cake/Web_www/noteBox/public%3E%0A%20%20%20%20%20%20%20%20%23PassengerAppRoot%20%20/home/User/web_ror/home/public%0A%20%20%20%20%20%20%20%20PassengerAppRoot%20%20/Users/User/Web_www/noteBox%0A%20%20%20%20%20%20%20%20Allow%20from%20all%0A%20%20%20%20%20%20%20%20Options%20-MultiViews%0A%20%20%20%20%20%20%20%20%23RailsBaseURI%20/rails%0A%20%20%20%20%3C/Directory%3E%0A%0A%3C/VirtualHost%3E%0A%60%60%60%0A%0A%23%23%23%23%20Laravel%20%u4E2D%20public/.htaccess%0A%0A%60%60%60%0A%3CIfModule%20mod_rewrite.c%3E%0A%20%20%20%20%3CIfModule%20mod_negotiation.c%3E%0A%20%20%20%20%20%20%20%20Options%20-MultiViews%0A%20%20%20%20%3C/IfModule%3E%0A%0A%20%20%20%20RewriteEngine%20On%0A%0A%20%20%20%20%23%20Redirect%20Trailing%20Slashes...%0A%20%20%20%20RewriteRule%20%5E%28.*%29/%24%20/%241%20%5BL%2CR%3D301%5D%0A%0A%20%20%20%20%23%20Handle%20Front%20Controller...%0A%20%20%20%20RewriteCond%20%25%7BREQUEST_FILENAME%7D%20%21-d%0A%20%20%20%20RewriteCond%20%25%7BREQUEST_FILENAME%7D%20%21-f%0A%20%20%20%20RewriteRule%20%5E%20index.php%20%5BL%5D%0A%3C/IfModule%3E%0A%60%60%60%0A%0A%0A%0A