Load an HTML file directly from public folder as View in Laravel
Just place the wedding folder directly inside the public folder:
mv wedding/ /path/to/laravel/public
Then visit your site URL with a wedding suffix:
http://my-site.com/wedding
This will load the index.html
from inside the wedding folder.
This works via Nginx's try_files
directive in your /etc/nginx/sites-enabled/my-site
config file:
location / { try_files $uri $uri/ /index.php?$query_string;}
This instructs Nginx to first search for an actual file corresponding to the URL (for example, /css/app.css
, /wedding/index.html
, etc). If it does not find a matching file (e.g. it would normally return a 404 not found), then it should instead pass the query string as an argument to the index.php script.
One solution is to rename your wedding invitation's index.html
to index.php
and place it within your resources/views
folder, so that it becomes a Laravel template.
cd path/to/laravelmkdir resources/views/weddingmv public/wedding/index.html resources/views/wedding/index.php
Then you can call it from your controller as you wish:
public function index(){ return view('wedding.index');}
Of course with this method you'll have to ensure any CSS/JavaScript/image urls are properly mapped to their respective locations within the public/
folder.