I'm slowly migrating my website into the artisan era using Laravel. I have it setup on AWS
on a vanilla Amazon linux.
Currently I have; www.example.co.uk
blog.example.co.uk
careers.example.co.uk
These are all on the same server and the subdomains have been achieved using htaccess
to redirect to \blog
and \careers
folders in my root
with DNS
being handled by Route 53
Now in moving to laravel
it only considers the public
folder (htaccess
use no longer required apart from the default one it comes with) so I have my DocumentRoot
as /var/www/example/public
. Everything works great! Setup a bunch of routes
for my main site and still smooth sailing.
Now moving to the subdomains, I have the below in my hhtpd.conf
<VirtualHost *:80>
ServerName blog.example.co.uk
ServerAdmin webmaster@blog.example.co.uk
DocumentRoot /var/www/example/public
<Directory /var/www/example/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/blog.example.co.uk.error.log
LogLevel warn
CustomLog /var/log/blog.example.co.uk.access.log combined
</VirtualHost>
As you can see I'm pointing the subdomain to the same public folder since Laravel
should be able to see that blog.example.co.uk
was requested and perform its duties to route correctly.
I have the below routes for the subdomain
Route::group(['domain' => 'blog.example.co.uk'], function () {
Route::get('/', 'BlogController@home')->name('blog-home');
Route::get('review', 'BlogController@review')->name('blog-review');
Route::get('author/{id}', 'BlogController@author')->name('blog-author')->middleware('blogGuard');
Route::get('category/{id}', 'BlogController@category')->name('blog-category')->middleware('blogGuard');
Route::get('post/{id}', 'BlogController@post')->name('blog-post')->middleware('blogGuard');
Route::get('press', 'BlogController@press')->name('blog-press');
Route::get('about', 'BlogController@about')->name('blog-about');
});
Unfortunately, going to blog.example.co.uk
still assumes that I requested www.example.co.uk
and routes using the logic for the main site. So blog.example
points to www.example
.
I have also used '{blog}.example.co.uk'
What am I doing wrong please Cheers!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire