Reputation: 108
I'm trying to create an app with laravel 4 but i'm facing a url issue. i have wamp installed on my machine. i set up a new virtual host in my httpd-vhost.conf with this code
<VirtualHost mobile.dev>
DocumentRoot "C:\wamp\www\mobile.dev\public"
ServerName mobile.dev
<Directory "C:\wamp\www\mobile.dev">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
Allow from 127.0.0.1
Deny from all
Require all granted
</Directory>
mobile.dev is a folder and also the domain name in my localhost. here is my Route.php file
Route::get('/','HomeController@showWelcome');
Route::post('login','LoginController@userLogin');
Route::get('login','LoginController@getUsers');
when i ask for mobile.dev/login it gives me the requested url was not found. can you help me please solve this issue. but when i ask for mobile.dev/ its working.
Here is my .htaccess file :
<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]
Here is more details. when i remove my htaccess content everything works fine with the default url http://mobile.dev/index.php/login
So the problem is in my htaccess and the rewriting in my virtual host
Upvotes: 0
Views: 5623
Reputation: 1570
It might be not Laravel problem, but seems your wamp server haven't enabled mod_rewrite
in httpd.conf
file yet. Locate the line -
#LoadModule rewrite_module modules/mod_rewrite.so
and remove the comment symbol '#'. Then save the file and restart Apache.
Upvotes: 5
Reputation: 108
Solution:
1- when you have wamp installed in your machine please go to C:\wamp\bin\apache\Apache*.*.*\conf\httpd.conf
and make sure that rewrite_mod is enabled by deleting the hash tag. (instead of using the interface provided by wamp)
2-there are two ways to enable rewriting for laravel in .htaccess file :
<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>
or using this :
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
3- if you're setting a virtual host be sure to add this option in the <virtualhost>
tag
<Directory "C:\wamp\www\mobile.dev\public">
Options FollowSymLinks Indexes Multiviews
AllowOverride All
</Directory>
Thanks a lot for your time.
Upvotes: 2
Reputation: 10049
Your <Directory "C:\wamp\www\mobile.dev">
in config should be <Directory "C:\wamp\www\mobile.dev\public">
to specify the public directory to the root of the htaccess rewrite rules.
I originally thought you were missing the </IfModule>
at the end of your .htaccess file but when I posted my .htaccess file it hid the </IfModule>
as well so that is a stack overflow issue. Otherwise your htaccess is correct.
Upvotes: 0
Reputation: 846
Have you tried
Route::post('login','LoginController@userLogin');
without the () after userLogin?
Upvotes: 1