


When laravel5.2 is transplanted to a new server, except for the '/' route, the pages corresponding to other routes display a 404 error (Object not found!)
1.服务器系统:linux系统
2.Web环境:lamp(Linux+Apache+Mysql+PHP)[使用的Linux版本的xampp软件集成包]
(1).不是storage和Bootstrap/cache文件夹权限问题。
(2).用laravel5.2做的项目在window系统本地端(wamp)测试其它页面显示可行。在Linux服务器(lnmp)环境测试其它页面也是可以显示。
回复内容:
1.服务器系统:linux系统
2.Web环境:lamp(Linux+Apache+Mysql+PHP)[使用的Linux版本的xampp软件集成包]
(1).不是storage和Bootstrap/cache文件夹权限问题。
(2).用laravel5.2做的项目在window系统本地端(wamp)测试其它页面显示可行。在Linux服务器(lnmp)环境测试其它页面也是可以显示。
1.打开 /etc/httpd/conf/httpd.conf(使用xampp: /opt/lampp/etc/httpd.conf).
2.确保DocumentRoot 指向的目录是laravel中public文件夹。如果不是需要改为如下:
<code>DocumentRoot "/var/www/html/laravel/public/" <Directory "/var/www/html/laravel/public"> Allowoverride All </Directory></code>
注意:(/var/www/html 是存放laravel目录。 一般linux默认是/var/www/html目录下,Xampp的是在/opt/lampp/htdocs/目录下。 使用xampp上面/var/www/html/laravel/public/ 改为/opt/lampp/htdocs/laravel/public/)
3.确定laravel public目录下.htaccess文件有下面的代码(如果没有请将下面代码添加进去):
<code><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></code>
4.重启Apache服务器。sudo service httpd restart (使用 Xampp的 :
先关闭:/opt/lampp/lampp stop 再重启:/opt/lampp/lampp start
详细参考:http://stackoverflow.com/questions/21458080/the-requested-url-projectname-users-was-not-found-on-this-server-laravel/24354757#24354757
url重写。
应该是URL重写的问题
Apache
Laravel 框架通过 public/.htaccess 文件来让网址不需要 index.php。如果你的服务器是使用 Apache,请确认是否有开启 mod_rewrite 模块。
如果 Laravel 附带的 .htaccess 文件在 Apache 中无法使用的话,请尝试下方的做法:
<code>Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </code>
Nginx
若你使用了 Nginx,则可以在网站设置中增加以下设置:
<code>location / { try_files $uri $uri/ /index.php?$query_string; }</code>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The main differences between Laravel and Yii are design concepts, functional characteristics and usage scenarios. 1.Laravel focuses on the simplicity and pleasure of development, and provides rich functions such as EloquentORM and Artisan tools, suitable for rapid development and beginners. 2.Yii emphasizes performance and efficiency, is suitable for high-load applications, and provides efficient ActiveRecord and cache systems, but has a steep learning curve.

To safely and thoroughly uninstall MySQL and clean all residual files, follow the following steps: 1. Stop MySQL service; 2. Uninstall MySQL packages; 3. Clean configuration files and data directories; 4. Verify that the uninstallation is thorough.

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.

macOS and Linux have their own advantages in compatibility and user experience. macOS has excellent compatibility within the Apple ecosystem, and the user experience is simple and intuitive; Linux has outstanding hardware compatibility and software flexibility. The user experience varies from distribution to distribution, emphasizing personalization and control.

Methods for configuring character sets and collations in MySQL include: 1. Setting the character sets and collations at the server level: SETNAMES'utf8'; SETCHARACTERSETutf8; SETCOLLATION_CONNECTION='utf8_general_ci'; 2. Create a database that uses specific character sets and collations: CREATEDATABASEexample_dbCHARACTERSETutf8COLLATEutf8_general_ci; 3. Specify character sets and collations when creating a table: CREATETABLEexample_table(idINT

Integrating Sentry and Bugsnag in Laravel can improve application stability and performance. 1. Add SentrySDK in composer.json. 2. Add Sentry service provider in config/app.php. 3. Configure SentryDSN in the .env file. 4. Add Sentry error report in App\Exceptions\Handler.php. 5. Use Sentry to catch and report exceptions and add additional context information. 6. Add Bugsnag error report in App\Exceptions\Handler.php. 7. Use Bugsnag monitoring
