show your routes please
remove index.php from laravel5.6
How to remove index.php from http://localhost/lvoffc/index.php/login where "lvoofc" is the name of my project.
http://localhost/lvoffc/index.php/login---> Working http://localhost/lvoffc/login---> Shows "The requested URL /lvoffc/login was not found on this server." http://localhost/lvoffc/index.php/register--> Working http://localhost/lvoffc/register--> Shows "The requested URL /lvoffc/login was not found on this server."
I have tried the options
- move the index.php and .htaccess from a public to root directory
- rename the server.php to index.php and move the .htaccess file to the root directory. but not getting success to remove index.php from URL
Just doing 2nd step is enough
@rin4ik Route::get('/', function () { return view('welcome'); });
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
This is my web.php file
@biishmar this is not working. i have tried
Apache Laravel includes a public/.htaccess file that is used to provide URLs without the index.php front controller in the path. Before serving Laravel with Apache, be sure to enable the mod_rewrite module so the .htaccess file will be honored by the server. If the .htaccess file that ships with Laravel does not work with your Apache >installation, try this alternative:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
EDIT:inside public directory you can find .htaccess file
Show me index.php and .htaccess
@biishmar This is .htaccess
Options -MultiViews -Indexes
RewriteEngine On
# 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]
this is index.php that is renamed from server.php to index.php
@vikdhr Your htaccess is fine..
require_once __DIR__.'/public/index.php';
Does your index,php has a last line like this?
@biishmar yes Sir
@biishmar I also enabled the rewrite module in apache
@vikdhr show me root/index.php and public/index.php
@biishmar This is root index.php
$uri = urldecode( parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ); if ($uri !== '/' && file_exists(DIR.'/public'.$uri)) { return false; } require_once DIR.'/public/index.php';
@biishmar this is index.php of public folder define('LARAVEL_START', microtime(true)); require DIR.'/../vendor/autoload.php'; $app = require_once DIR.'/../bootstrap/app.php'; $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle( $request = Illuminate\Http\Request::capture() ); $response->send(); $kernel->terminate($request, $response);
@vikdhr cant see the code
@biishmar please check i remved <?php now it is visible
@vikdhr Public/index.php
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <[email protected]>
*/
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__.'/../bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
root/index.php
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <[email protected]>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
check those both and tell you have same in ur both index.php
@biishmar Public/index.php where require DIR.'/../bootstrap/autoload.php'; it is as require DIR.'/../vendor/autoload.php';
If vendor is replaced with bootstrap then it shows blank screen
@rin4ik i tried the options given on the links
@vikdhr Yes both r needed, if u find anything different in your index.php change it like this or copy paste this both index.php..
@biishmar can you please provide the exact public/index.php ?
@biishmar as you say i wrote as
require DIR.'/../vendor/autoload.php'; require DIR.'/../bootstrap/autoload.php';
but not working
@biishmar i worked on laravel 5.4 version by moving the index.php and .htaccess file from public to root and making changes in index.php that works fine but not in version laravel5.6
@vikdhr What i paste here is exact one
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <[email protected]>
*/
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__.'/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
@biishmar This is same Sir.
@biishmar and @rin4ik running this http://localhost:8000/login works
@vikdhr what was the problem?
@rin4ik i can access http://localhost/lvoffc/index.php/login where "lvoffc" is my project name but i can not access http://localhost/lvoffc/login it shows The requested URL /lvoffc/login was not found on this server. Apache/2.4.18 (Ubuntu) Server at localhost Port 80
@vikdhr oh man. it will never work sorry. your project name is this http://localhost:8000. I didn't think about it. your project works fine don't worry. it is just full path that's way it works http://localhost/lvoffc/index.php/login. you can't remove here index.php it is full path. if you are using php artisan serve all your routes begins with http://localhost:8000 it is your home route in this case index.php excluded. you login route http://localhost:8000/login your register route is this http://localhost:8000/register and so on. forget about your project name. if you are using homestead or valet you can name your project as lvoffc.test and then you can go to this route lvoffc.test/login. for now use just http://localhost:8000 as the name of your project
Please or to participate in this conversation.