问题
As the title states, I cannot get my site to redirect. I've made several attempts and am about to lose it.
My .htaccess file is as follows:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
I have this file placed in the www/Laravel/public folder as well as www directory
- mod_rewrite is enabled
- AllowOverride is set to All
My host file is as follows
127.0.0.1 localhost
Here is the code for route contained in routes.php
Route::get('authors', array('uses'=>'authors@index'));
I have a controller named authors.php, here is the code
class Authors_Controller extends Base_Controller {
public $restful = true;
public function get_index () {
return View::make('authors.index');}
}
I am using Windows 7 Ultimate. I'm about to blow my brains out. Please help me, I suck.
回答1:
If your laravel project is located in c:\wamp\laravel\ then you should be able to call
http://localhost/laravel/public
and see the default laravel welcome page or your own.
If thats the case, you have to check two thins:
- Open your /app/config/app.php file and check that the value of url directs to your project.
'url'=>'http://localhost/laravel/
- Then open your .htaccess file and add the RewriteBase rule under the
RewriteEngine On
LineRewriteBase /laravel/public/
Hope that helps! :)
回答2:
I had the same problem. I used the solution above and it worked.
Apache rewrite_module must be enable in wamp as well.
回答3:
You need to setup a virtual host pointing to your public directory... in httpd.conf file.
Which can be found under the Apache menu...
Like so...
<VirtualHost *:80>
DocumentRoot c:\wamp\www\laravel\public
ServerName testing.com
</VirtualHost>
And your hosts file will reflect the url you choose...in this case...testing.com
127.0.0.1 testing.com
回答4:
Checking rewrite_module
Go to
- wamp icon
- Apache
- Apache modules
- check
rewrite_module
And cheers , there you are after some headache
回答5:
Apache rewrite_module
must be enabled in WAMP as well. It works with my wampserver.
回答6:
Actually it has a pretty easy solution. All you have to do just check the rewrite module in apache. Check the steps in image laravel problem with wamp server solution
回答7:
Create an index.php file in the root.
<?php
header("refresh: 0; http://localhost/appnamehere/public");
?>
If you have multiple sites under one domain, you may not be able to change your public webroot.
I had all the correct settings, and the right .htaccess files in the right place, but it would not redirect. This fixed it for me.
This article was helpful in getting the wampserver/wampmanager links working. Project Links do not work on Wamp Server
Post Script:
If you add to the virtual host file at: E:\wamp\bin\apache\apache2.4.23\conf\extra\httpd-vhosts.conf and you create a virtual host that points to the public directory like this:
<VirtualHost *:80>
ServerName Blog
ServerAlias Blog
DocumentRoot E:/wamp/www/Blog/public
<Directory "E:/wamp/www/Blog/public/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
#
and you add to C:\Windows\System32\drivers\etc\hosts
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
127.0.0.1 Blog
::1 Blog
You do not need the index.php file I suggested. That file works if you are NOT creating a virtual host, both are not needed. It's one or the other (although it does no harm to have it).
回答8:
They only right way to do this is to point web server to public
directory. For example, if you've installed Laravel in C:/xampp/htdocs/
directory, you need to use these settings:
DocumentRoot "C:/xampp/htdocs/public"
<Directory "C:/xampp/htdocs/public">
Never edit .htaccess
inside public folder. If you did this, you need to get original file back. Restart Apache after you make these changes.
来源:https://stackoverflow.com/questions/15607132/laravel-route-not-working-with-wamp