Reputation: 1843
I have a Laravel install that is using the standard .htaccess
file, which works great for dev.mysite.com
but on my dev server I have foo.dev.mysite.com
and another route which is bar.dev.mysite.com
The routing is working fine, but the requests are not being rewritten to index.php, for example when I go to foo.dev.mysite.com/example
I get a 404 but when I go to foo.dev.mysite.com/index.php?example
it's working fine.
I have the following .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>
Upvotes: 0
Views: 688
Reputation: 722
First, make sure mode_rewrite is enabled. I am sure you have probably done this but I want to make sure nothing is missed. Another test is to remove the IfModule
condition and see if it fails.
Next, see what version of apache you are running since the syntax has changed between 2.2 and 2.4. The Optons
default was changed from All
to FollowSymlinks
in 2.3.11. This should not be a big deal and doubt this is the culprit but could be and save you trouble in the future.
Next, try putting the rewrite condition inside of the vhost information instead of the htaccess file. This can help a little with performance as well as give you a console warn/err when restarting apache where the htaccess errors could be squelched.
<directory /var/www/mysite.com>
Options -MultiViews
AllowOverride ALL
RewriteEngine On
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</directory>
Beyond this point I would be at a loss without some more logging or information from the server. You can also add CustomLog
into the vhost and report all requests processed by the server.
Upvotes: 1