Kailaash Balachandran
Kailaash Balachandran

Reputation: 419

Can Laravel 5.1 application run without .htaccess rewrite?

So my university's webmaster says the server space they allotted me does not support htaccess rewrite rules. But from my understanding of Laravel, .htaccess must be enabled. Are there any workaround for this?

My .htaccess code goes like this

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

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

    RewriteBase /
    RewriteRule ^.+/experiment/(.*)$ /experiment/$1 [L,NC,R]
</IfModule>

Upvotes: 2

Views: 1557

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163898

No it can't. Laravel uses the only .php file which is index.php and if you'll remove .htaccess you'll not be able to use some of Laravel features like routing.

After some modifications, you'll be able to make it work, but in the end of this, you'll have ugly URLs like /index.php/hello-page and some hard-to-fix errors.

The only good option here is to buy some cheap webhosting.

Upvotes: 3

Related Questions