Good day,
i have a laravel project running under domain.co.zw and domain root folder is pointing to public_html. I then created a subdomain but it is pointing to a subfolder called mainsystem which is under then public_html.
Now i have condifguired the htaccess for the website in public_html, hoow best can i configure for the laravel app in subfolder mainsystem with domain database.domain.co.zw
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ mainsystem/$1 [L]
</IfModule>
My Answer:
You can create a separate .htaccess file in the mainsystem subfolder to configure the Laravel app. Here is an example of how you can configure the .htaccess file for the Laravel app in the mainsystem subfolder:
RewriteEngine On
RewriteBase /mainsystem/
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Make sure to update the RewriteBase to match the subfolder path where your Laravel app is located. This configuration will ensure that all requests to the mainsystem subfolder are handled by the Laravel app's index.php file.
Additionally, you may need to update the database configuration in your Laravel app to point to the correct database (database.domain.co.zw). You can do this by updating the .env file in your Laravel project with the appropriate database connection details.
Once you have configured the .htaccess file and updated the database configuration, your Laravel app should be accessible via the subdomain mainsystem.domain.co.zw.
Rate this post
3 of 5 based on 3908 votesComments