Laravel 4 remove Index.php from URL

2019-01-28 04:07发布

I need some help with laravel 4 application i need to remove Index.php from url i have tried the solution that has been mentioned in laravel documentation

Pretty URLs
Apache

The framework ships with a public/.htaccess file that is used to allow URLs without index.php. If you use Apache to serve your Laravel application, be sure to enable the mod_rewrite module.

If the .htaccess file that ships with Laravel does not work with your Apache installation, try this one:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

any Suggestions :) ?

7条回答
爷、活的狠高调
2楼-- · 2019-01-28 04:34

just go to your apache settings folder, i use wamp so myne is

C:/wamp/bin/apache/apache2.4.9/conf/httpd.conf - file

   // located on line 154 precisely... 

    #LoadModule rewrite_module modules/mod_rewrite.so  

   // to 

    LoadModule rewrite_module modules/mod_rewrite.so 

restart WAMP and BOOM!.. it works.

查看更多
够拽才男人
3楼-- · 2019-01-28 04:41

this worked for me

<Directory "/var/www/html">` 
    AllowOverride All
</Directory>
查看更多
相关推荐>>
4楼-- · 2019-01-28 04:41

uncomment 'LoadModule rewrite_module modules/mod_rewrite.so' in apache httpd.conf in 'public' folder check .htaccess file (created by default)

<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>
查看更多
你好瞎i
5楼-- · 2019-01-28 04:44

Try this:

a2enmod rewrite

And it will works

查看更多
成全新的幸福
6楼-- · 2019-01-28 04:48

mod_rewrite apache module may not be enabled by default. enable it and retry.

查看更多
Emotional °昔
7楼-- · 2019-01-28 04:52

I have read long posts and threads but nothing works then i found this and it works for me.

The easiest way to do this (and the way I always use) is to open up your Command prompt or Terminal and cd into the main directory of your project then run "php artisan serve". That's it. You're done. Don't believe me? Check out http://localhost:8000 and admire your Laravel work.

http://michaelbrooks.co.uk/post/laravel-localhost-removing-public-index-php

查看更多
登录 后发表回答