Fraser
Fraser

Reputation: 14246

Laravel htaccess issue

I'm trying to set a site live. The site works perfectly fine on a live dev server which we've been using to show the site to the client. Here is the htaccess from the live dev (works fine):

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On

    #RewriteCond %{HTTPS} !=on
    #RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
    #RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    # Rewrite to 'public' folder
    RewriteCond %{HTTP_HOST} ^livedev.domain.com$
    RewriteCond %{REQUEST_URI} !public/
    RewriteRule (.*) public/$1 [L]
</IfModule>
AuthType Basic
AuthName "dev16"
AuthUserFile "/home/site/.htpasswds/public_html/passwd"
require valid-user

And here's the .htaccess from the live site:

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On

    #RewriteCond %{HTTPS} !=on
    #RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
    #RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    # Rewrite to 'public' folder
    RewriteCond %{HTTP_HOST} ^livesite.co.uk$
    RewriteCond %{REQUEST_URI} !public/
    RewriteRule (.*) public/$1 [L]
</IfModule>

The 2 are identical except for the HTTP_HOST and the removal of the authentication.

It gives me a generic "Internal Server Error".

I have tried deleting the contents of .htaccess which just gives me page not found so the issue definitely lies in .htaccess.

A total .htaccess virgin, what steps can I take to find the cause of the issue?

Thanks

(It's Laravel 3.2.13)

Upvotes: 10

Views: 13293

Answers (2)

ruuter
ruuter

Reputation: 2533

I had exactly same setup as RamiroRS answer, but still got Internal Server Error. My problem was in file permissions. Folders should be 0755 and files 0644.

Upvotes: 0

RamiroRS
RamiroRS

Reputation: 461

Use at same level of /public

This way first redirect to public

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]

And inside /public

then, you handle index.php

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
</IfModule>


<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Upvotes: 7

Related Questions