Created
November 5, 2019 19:51
-
-
Save newvertex/a8bfa521262cfcf5932db971d50ad6e7 to your computer and use it in GitHub Desktop.
simple config to use laravel subdomain route in shared host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <IfModule mod_rewrite.c> | |
| <IfModule mod_negotiation.c> | |
| Options -MultiViews -Indexes | |
| </IfModule> | |
| RewriteEngine On | |
| # Force to use www just for main domain, not for any subdomain | |
| RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ [NC] | |
| RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE] | |
| # Handle Authorization Header | |
| RewriteCond %{HTTP:Authorization} . | |
| RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | |
| # 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] | |
| </IfModule> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Laravel route settings in web.php file | |
| // if we want to use subdomain route we have to keep them all at the top of the main domain routes | |
| Route::domain('admin.example.com')->group(function () { | |
| Route::get('/', function () { | |
| return "hello from admin subdomain!"; | |
| }); | |
| }); | |
| // Use Vue.js as SPA then we have to redirect any request to api but just show index file ;-) | |
| Route::view('/{any}','index')->where('any', '^(?!api).*$'); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wwwrecord from domain zone editor before anyting elsepublic_html