2015-07-02 07:26
浏览 44

Laravel 5路由使用服务器

I installed Laravel 5 on a ftp server. Everything is fine, the main page is enable. But I have a problem with my routes. A link is calling a route which is calling a controller which is returning a view.

My link :

<div class="logo"><a href="{{ route('accueil') }}"><img src="images/logo.png" alt=""></a></div>

My route :

Route::get('/', [
'as' => 'accueil',
'uses' => 'ControllerTest@accueil']);

My controller :

class ControllerTest extends Controller
    public function accueil()
        return view('accueil');


But when I look to my element, I can see this : href="http://XX.XXX.XX.XXXC:/test/public/index.php" instead of href="http://XX.XXX.XX.XXX/test/public/index.php"

It seems like Laravel is mixing the server's IP and the localhost. I can't find what's wrong. I searched online a solution, but I always have this issue.

There is my .htaccess file in /public folder

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

RewriteEngine On
RewriteBase /test

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

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /index.php [L]

And there is my httpd.conf file used by apache.

<VirtualHost *:80>
  DocumentRoot C:/htdocs
  RewriteEngine On
  RewriteOptions Inherit 
  <Directory "C:/htdocs">
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted

And, I have enable the rewrite_module in the same file (httpd.conf) like this :

LoadModule rewrite_module modules/

I don't understand why it can't work. If someone has an idea to help me.

Thanks for reading.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

相关推荐 更多相似问题