简体   繁体   中英

Laravel 5 - .htaccess (index.php)

so I was asked to deploy an out-of-the-box laravel project done by other developer. It uses laravel 5, and is set up in IIS Manager.

Now we are doing some features upgrading of the website and I want to run this website on my localhost. I am using XAMPP.

I have copied the whole folder from the live web server and done the database configuration perfectly.

Now, I can view the homepage with no problem.

FYI, the folder structure is like this

C:/xampp/htdocs/myproject/
-app
-aspnet_client
-bootstrap
-config
-css
-database
-images
-js
-logs
-resources
-storage
-tests
-touchtouch
-vendor
.htaccess
index.php
package.json
server.php
...

Now, I can run "localhost/myproject" and load the homepage perfectly, but when I run this link eg localhost/myproject/aboutus, it says

Sorry, the page you are looking for could not be found.
NotFoundHttpException in RouteCollection.php line 145:

while if I run this localhost/index.php/aboutus it loads perfectly.

my htaccess is:

php_flag xcache.cacher 0
<IfModule mod_rewrite.c> 
<IfModule mod_negotiation.c> 
    Options -MultiViews 
</IfModule>  
Options +FollowSymLinks 
RewriteEngine On 
RewriteBase /MyProject/ 
# Redirect Trailing Slashes... 
 RewriteRule ^(.*)$index.php /$1  [L,R=301]  
# Handle Front Controller... 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^ index.php [L] 
</IfModule>

My config/app.php url is " http://localhost " if this matters.

and I have turned on the LoadModule rewrite_module modules/mod_rewrite.so

am I missing anything? thank you for your help.

I have fixed it. the problem lies on the RewriteBase; my real folder was MyProject, and I just renamed it to all small letter and it now works like charm.

I changed my .htaccess

php_flag xcache.cacher 0
<IfModule mod_rewrite.c> 
<IfModule mod_negotiation.c> 
    Options -MultiViews 
</IfModule> 
RewriteEngine On 
RewriteBase /myproject/

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


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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM