So, I'm running xampp on Windows. I'm currently trying to get familiar with the laravel framework. Now, when thats pointed out. How can i be able to access my laravel application/website direct within the root?
Example,
Any good solutions for this? do i need to add a .htacess file on the root folder of laravel? (not the public one).
Any suggestions?
Create or edit the . htaccess file in the Laravel root directory and configure the RewriteRule to remove “public/index. php” from the URL. You must have mod_rewrite enable on your Apache server.
Laravel provides several helpers to assist you in generating URLs for your application. These helpers are primarily helpful when building links in your templates and API responses, or when generating redirect responses to another part of your application.
Easiest way is create .htaccess
file in your Laravel root with following content:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
It should be redirected easily.
Reference: https://coderwall.com/p/erbaig/laravel-s-htaccess-to-remove-public-from-url
Here's how I did it.
Windows can be a real PITA when trying to edit the Hosts file because of the User Account Control. Since I work on all kinds of small hobby projects, I have to edit this file all the time so this is what I do.
At the bottom of the file, add this:
127.0.0.1 laravel.dev
This tells Windows to point the web browser to localhost whenever you enter laravel.dev in the browser's address bar.
At the bottom of the file, add this: (I am assuming xampp is installed at the root of the D: drive)
<VirtualHost *:80>
ServerName laravel.dev
DocumentRoot "D:/xampp/htdocs/laravel/public"
<Directory "D:/xampp/htdocs/laravel/public">
</Directory>
</VirtualHost>
Add an htaccess file to your laravel/public folder (if its not already there). I think the default htaccess file that comes with L4 looks like this:
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
http://laravel.dev
http://laravel.dev/about
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With