Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess affects directory in the sub domains

Consider this is my domain www.example.com

I am using laravel in my website

This is the laravel structure

app/
bootstrap/
public/
vendor/
server.php

To remove the index.php and public from the url i followed this answer

i.e.,

had the .htaccess in the root path

and renamed the server.php file as index.php

Here is my .htaccess

<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]

It works good, but the problem is i am having subdomain as

projects.example.com

While i create a sub directory here i.e.,

projects.example.com/firstproject

It always shows the internal server error

How can i fix this like, having exception to that directory or something like that ?

like image 832
AngularAngularAngular Avatar asked Dec 05 '25 13:12

AngularAngularAngular


1 Answers

The htaccess file affects the directory the file is in and all subdirectories. If you have subdirectories that you don't want mod_rewrite rules to affect, then you need to add an htaccess file with in the subdirectory with the rewrite engine turned on (so that none of the parent rules have precedence).

Just add this to an htaccess file in your subdirectory without any actual rules:

RewriteEngine On
like image 127
Jon Lin Avatar answered Dec 07 '25 01:12

Jon Lin