Dlaugh14
Dlaugh14

Reputation: 313

htaccess for domain and subdomain with laravel

I'm trying to figure out how to set up a domain and subdomain to work on a shared hosting account. It is a Laravel 5.1 application.

My access file is

Options +SymLinksIfOwnerMatch

RewriteEngine On

RewriteRule ^ index.php [L]

I just purchased another domain and added it on, but I get a 500 error. I renamed the access file and then it worked. So it has something to do with the access file. Essentially I want two separate domains with and I'm wanting two separate laravel applications, one for each.

I'm not familiar with atacceess.

Upvotes: 1

Views: 3092

Answers (2)

Dlaugh14
Dlaugh14

Reputation: 313

Olaf Dietsche's answer does work for me.

Here is another thing I came upon a website that also worked just before I saw his post. I guess I was reading that this would send a 404 to that directory.

Options +SymLinksIfOwnerMatch

RewriteEngine On

RewriteRule ^ index.php [L]

            RewriteCond %{HTTP_HOST} ^(www.)?main-topdomain.com$ [NC]
            RewriteCond %{REQUEST_URI} ^/subdomain-folder/(.*)$
            RewriteRule ^(.*)$ - [L,R=404]

So along with this comes another question if anyone is in my boat. I have my subdirectory inside of my root directory.***

dlaugh.com/public_html

laravel folders and access** inluding

app
bootstrap
config
database
etc...

but also I have my sub folder

    app
    bootstrap
    config
    database
    etc...
    **mysubdomain in that folder**

Is it better practice to put

-main_domain_folder and
-subdomain_folder
in public_html
and then the
/app
/config
/database

would be in the main_domain_folder rather than passing the subdomain through the main domain?

Upvotes: 0

Olaf Dietsche
Olaf Dietsche

Reputation: 74078

Maybe, you get a redirect loop, because the rule isn't protected by a condition. Although the default htaccess of Laravel should already contain them.

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

Upvotes: 1

Related Questions