The requested URL /ProjectName/users was not found on this server. Laravel

后端 未结 7 2030
天涯浪人
天涯浪人 2020-12-01 19:57

I am following the quickstart of laravel and it said \"type /users\" but not working for me. I have wrote in the browser, http://DomainServer/ProjectName/

相关标签:
7条回答
  • 2020-12-01 20:26

    Steps for Apache Web Server and Laravel in Linux Environment.

    1. Open httpd.conf

      sudo vim /etc/httpd/conf/httpd.conf
      # for debian users: /etc/apache2/apache2.conf
      
    2. Make sure the DocumentRoot is pointing to the laravel project's public directory

    3. Add the Directory element for that path and Allowoverride All... as follows

      DocumentRoot "/var/www/html/laravel/public/"
      
      <Directory "/var/www/html/laravel/public">
      Allowoverride All
      </Directory>
      
    4. Open .htaccess from ../laravel/public/ and make sure it has the following

      <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>
      
    5. Restart httpd services

      sudo service httpd restart
      
    6. Now http://DomainServer/users will work in your browser.

    0 讨论(0)
  • 2020-12-01 20:29

    Try pointing your browser to http://DomainServer/ProjectName/public/users - the 'public' folder is the default 'entry point' for your Laravel app.

    0 讨论(0)
  • 2020-12-01 20:34

    For me i enabled the mod_rewrite and it worked for me well. Enable mod_rewrite for Apache: cd /etc/apache2/sites-available/ sudo a2enmod rewrite

    0 讨论(0)
  • 2020-12-01 20:36

    Make sure you have mod_rewrite enabled in Apache .

    0 讨论(0)
  • 2020-12-01 20:42

    Find httpd.conf and change the <Directory> element from

    <Directory "/var/www/html/">
    Allowoverride None
    </Directory>
    

    to

    <Directory "/var/www/html/">
    Allowoverride All
    </Directory>
    

    Then it works after restart the apache without change the DocumentRoot.

    0 讨论(0)
  • 2020-12-01 20:44

    the default url have a prefix "index.php" before your page if you try .../public/index.php/your_page it will run, so you need to add the module rewrite if you are using appache to write your url without this prefix

    0 讨论(0)
提交回复
热议问题