【问题标题】:Remove index.php for laravel framework删除 laravel 框架的 index.php
【发布时间】:2017-12-12 15:07:53
【问题描述】:

我有 laravel 框架, 我试图隐藏 index.php,但是当我更改了我的 .htaccess 文件(在 Public_Html 下)时,它无法正常工作。 像-如果我用通用代码隐藏 index.php,那么除了 home 之外的所有 url 都不起作用。但是如果我在这种情况下使用 mydomain.com/index.php/contactus ,它就可以工作。 请检查代码和帮助

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

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_URI} "/application/"
RewriteRule (.*) $1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{THE_REQUEST} ^.*/index\.php 
RewriteRule ^(.*)index.php$ /$1 [R=301,L]

【问题讨论】:

  • 查看link。它还可以帮助您解决与 apache 相关的设置。

标签: laravel .htaccess


【解决方案1】:
<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>

这应该做正确的工作

【讨论】:

    猜你喜欢
    • 2012-12-30
    • 2012-03-26
    • 2014-10-10
    • 2012-12-22
    • 2017-05-19
    • 2015-07-26
    • 1970-01-01
    • 1970-01-01
    • 2018-03-04
    相关资源
    最近更新 更多