laravel 去掉index.php

1,首先,讓apache服務器支持rewrite  php

    能夠在apache配置文件中定義rewrite規則,是全局的,不管哪一個應用都實用
laravel

    //httpd.configapache

        Listen 80服務器

        RewriteEngine on   ---將rewrite開啓app

        LoadModule rewrite_module modules/mod_rewrite.so  前面的註釋去掉ide

        在Directory中配置:網站

        <Directory "/www/poem/public">spa

            Options Indexes FollowSymLinksget

            AllowOverride All        ----這項必定要進行修改it

            Order deny,allow

            Allow from all

        </Directory>

2,配置.htaccess文件  ---find / -name .htaccess 來查找此文件

    <IfModule mod_rewrite.c>

        Options +FollowSymLinks

        RewriteEngine On

    </IfModule>

    <IfModule mod_rewrite.c>

        RewriteCond %{REQUEST_FILENAME} !-f

        RewriteCond %{REQUEST_FILENAME} !-d

        RewriteRule ^(.*)$ index.php/$1 [L]    ---這句話的含義是:任何訪問網站的路徑都映射成index.php/xxx,其中xxx是$1 與 (.*)中的內容進行匹配  例如咱們輸入http://192.168.0.222/about  -->http://192.168.0.222/index.php/about

    </IfModule>

3,若是是專門針對laravel進行配置,則在app/app.php中加入

    index=>'',   //laravel4.1中沒有此項,直接手寫加入便可

相關文章
相關標籤/搜索