How to run a Laravel project Without Artisan Command
Today, we will explain Laravel how run Laravel without php artisan serve command. Laravel that every time run the php artisan serve command in command prompt. But it takes every time take time, so it’s time-consuming. You will learn how to run a Laravel project Without Artisan Command using the .htaccess file.
First, install Laravel. Also Read: How to Install Laravel and Basic Configuration
Example 1:
Rename File
Rename the server.php to index.php in your project root directory.
project/server.php rename to project/index.php
htaccess File
Move your .htaccess from public folder to root directory.
project/public/.htaccess move to here project/.htaccess
Now browser run : https://devnote.in/project_name
Important Notice :
You using Apache “virtual hosts” (The /public folder in Laravel) instead of renaming server.php to index.php. this you will need to prefix public/ when you use the Laravel asset() function in your views. And also check https://your_domain.com/.env file is not readable. If the .env file is readable, add the below code in the .htaccess file.
<Files .env>
Order allow,deny
Deny from all
</Files>
Example 2:
Create a new .htaccess file inside the project root directory. this way is the best way.
#project/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php
</IfModule>
when i choose login it give me The requested URL was not found
Thanks for sharing this trick