2016-11-28 80 views
0

http://localhost/projectname/admin正常工作,但是當我試圖執行相同的http://localhost/projectname/admin/其給予「對象未找到!」錯誤404/在URL不工作laravel

這是我.htaccess

<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_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule^index.php [L] 

# Handle Authorization Header 
RewriteCond %{HTTP:Authorization} . 
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 

怎麼能I /解決這個與尾隨的網址是什麼?提前致謝。

+0

那你只需要添加'/''後url'? –

+0

是的先生。兩者都應該使用和不使用「/」進行相同的重定向。 –

+0

https://www.slimframework.com/docs/cookbook/route-patterns.html將幫助你。這是違反API最佳實踐的。 –

回答

0

嘗試這樣的代碼中的財產以後你.htaccess文件

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)/$ /$1 [L,R=301] 

也可以嘗試這個...

RewriteCond %{REQUEST_URI} !\.(php|html?|jpg|gif)$ 
RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301] 
+0

沒有pravin我有同樣的錯誤。 –

+0

嘗試在以下htaccess代碼... –

+0

我試過但沒有工作。我應該用這個替換我當前的htaccess還是隻需要附加它或覆蓋任何現有的行? –

0
Replace your .htaccess confg with 
<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_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule^index.php [L] 

</IfModule> 
+0

thnx爲答案,但仍然輸出與以前一樣。請給我其他解決方案。 –

0

在你的Apache配置文件中設置的AllowOverrideAll然後重新啓動你的Apache,它應該正常工作。

DocumentRoot "/Library/WebServer/Documents" 
<Directory "/Library/WebServer/Documents"> 
    # 
    # Possible values for the Options directive are "None", "All", 
    # or any combination of: 
    # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews 
    # 
    # Note that "MultiViews" must be named *explicitly* --- "Options All" 
    # doesn't give it to you. 
    # 
    # The Options directive is both complicated and important. Please see 
    # http://httpd.apache.org/docs/2.4/mod/core.html#options 
    # for more information. 
    # 
    Options FollowSymLinks Multiviews 
    MultiviewsMatch Any 

    # 
    # AllowOverride controls what directives may be placed in .htaccess files. 
    # It can be "All", "None", or any combination of the keywords: 
    # AllowOverride FileInfo AuthConfig Limit 
    # 
    AllowOverride All 

    # 
    # Controls who can get stuff from this server. 
    # 
    Require all granted 
</Directory> 

PS:

須藤服務的Apache2重啓

+0

並使用laravel的默認htaccess文件。 –