I have a laravel project which I run from my local apache server directory.
The link for accessing this project is
www.localhost/project.dev/public/index.php
And I have a navigation menu
After I have set the APP_URL in .env file to
http://localhost/blog.dev/public/index.php/
I get no problems while navigating through the About and Contact pages in the project but when I access the Home page the browser goes to the
http://localhost/
but not to the
http://localhost/blog.dev/public/index.php/
How can I fix it? Here are my routes:
Route::get('/', 'PagesController#getIndex');
Route::get('about', 'PagesController#getAbout');
Route::get('contact', 'PagesController#getContact');
I think the best way is to setup a vhost in apache. if you want to work like this in your .env set the APP_URL= http://localhost/blog.dev/public/
Run php artisan serve in command line. The laravel buil-in server will active. And you will able to access your laravel application using correct url as like http://localhost:8000 try this and let me know if you have any problem.
Related
im new in laravel so im just try to run laravel without php artisan and read much topics about run laravel without php artisan but the main problem is the main route (/) is working and run (home view) but other routes like (/about) in web file doesnt work. so how can i run other views via routes (web file)?? i tried many ways for run laravel without php artisan but im stuck in this part routes. without routes, laravel is completely useless. i moved index.php from public folder and .htaccess to the root folder for run laravel wihout php artisan like this:root folder laravel
and this my index.php so i changed it to run from root not public folder:
index.php file
and .htaccess:
.htacess file
and finally this is my web file which is my routes:
web.php
when i set routes about and try to go to that, the error 404 is shown up: error 404 /about route
so how can i set routes and actualy the main problem is how can i request and Recieve urls from root without php artisan. and another way that i tried is rename server.php to index .php and i could say none of this ways are working. it just show the root home page not working for other routs. thanks
Route::get('/admin', 'Backend\HomeController#index')->name('admin.home');
is from routes/web.php and it's not working online. It's fine in local
Route::get('/superadmin', 'Backend\HomeController#index')->name('admin.home');
or any name except 'admin' is working online and local.
But I've already used /admin in my project in many places.
That's why I can't use /superadmin.
Please Help.
website backend:
http://ischebazar.com/admin
login:
http://ischebazar.com/admin/login is working.
I can't comment so I need to post an answer for this.
What do you mean by it does not work? Does it show you the laravel 404 page, a server error or a blank page?
If it shows you the laravel 404 page try clearing the route cache: php artisan route:clear.
If it's a blank page, try checking if you have a folder called admin in the document root of the project.
For a server error I can't guess whats wrong but you can provide additional information if this is the case.
Try executing the following command to clear out cache,
php artisan config:cache
I've encountered a problem while creating simple apps with Laravel on IIS.
When I create a new Laravel application I can see the Laravel welcome page just fine.
If I create another view in the same folder as the welcome.blade.php (test.blade.php for example), and set up the route for that in routes/web.php I can't navigate to that page in browser. EDIT: When I attempt this I get a 404.
My web.php is as follows:
<?php
Route::get('/', function (){
return view('welcome');
});
Route::get('/test', function (){
return view('test');
});
At first I thought that perhaps the project was not reading web.php, but when I run php artisan route:list the test route is listed.
I thought perhaps that my view didn't work, so I renamed it as welcome.blade.php and that loaded up fine. I just seem to be unable to add a route to any view or anonymous function that isn't mapped to welcome.blade.php
I tried adding a static route.php file into the app directory with the same code, but that made no difference to the result.
I'm sure I must be missing something basic, but I can't seem to put my finger on where I've gone wrong. Would massively appreciate any help you might be able to offer. Thank you.
Right I worked out where I went wrong. I hadn't run artisan serve. Very simple.
If you're having this problem, try navigating to your application root in cmd and then try
php artisan serve
Then navigate to your page using that information.
Thank you to everyone who posted, massively appreciated.
You need to install Url Rewrite in your terminal. Then import the .htaccess file located in your project/public folder.
To install Url Rewrite, you need to install Web Platform Installer (WPI). Once installed, open WPI then search for the keyword "Url Rewrite", then install the first item in the result. Once the download is finished, Url Rewrite will be available in your IIS Manager
I think IIS server maybe blocks test url.
IIS server has such features.
Before time, I remember that I used IIS blacklist url feature.
You may check IIS url block feature.
I just installed laravel following the instruction on Larvel docs. I chose to use install via composer create project command.
In the routes. php i created a dummy route
Route::get('/', function(){
return 'Front Page';
});
When i access http://localhost/mysite/ It shows directory listing of mysite folder. However when i use http://localhost/mysite/server.php It runs my route closure.
I also tried alternate .htaccess code provided at Laravel's docs but that doesn't work either.
I want to remove the server.php from url.
Thanks in advance for help.
This behavior is expected and this is how Laravel works. The public folder is meant for assets and is also (supposed to be) the webservers root directory.
If you are working on localhost that is not the case and the root directory contains multiple projects.
In order to get rid of public you would have to change virtual host settings.
As mentioned here in the site.
The problem with doing virtual hosts is that other projects in localhost will become inaccessible.
Quick question,
EDIT: I do not know how to access other routes besides '/'
Here are the routes I want to access
Route::get('/', 'HomeController#index');
Route::get('users', 'UserController#index');
Route::get('foo', function()
{
return 'Hello World';
});
Here is my routes. Via php artisan routes
I can successfully access localhost/cartraderlaravel/public
It takes me to HomeController#index
when I try to access foo or users I get
I have tried
localhost/cartraderlaravel/public/users
localhost/cartraderlaravel/users
localhost/cartraderlaravel/foo
localhost/cartraderlaravel/public/foo
All of these return a "Not Found" error. Help anyone?
You should point your root directory to cartraderlaravel/public in WAMP so that you need not to visit localhost/cartraderlaravel/public. To do that in WAMP follow :
Click on WampServer icon in taskbar
Select Apache > httpd.conf from the pullup
Search for the term “DocumentRoot”
Change the DocumentRoot path to your custom directory
Search again for “DocumentRoot” again same procedure
Save your changes and “Restart All Services”
Further research shows this is a common problem with WAMP. Something to do with Apache settings. I have moved to using a virtual network and everything works now