0

I m newly working on laravel.

I created laravel project named as "blog" on localhost and for removing public/index.php, I followed following process :

  1. cut and pasted .htaccess from public/ folder to root i.e. blog
  2. Renamed the server.php to index.php
  3. Then I created a test api in api.php route and echoed "Hello World".

Now when I go to project path from my localhost server like: localhost/Blog/api/test then its work properly.

But when I run same on a server like 192.101.111.555,like : 192.101.111.555/Blog/api/test then it showing NOT FOUND.

I am not getting how can I resolve this. And why its working fine on localhost but not working on server ?

Mohammed Sabir
  • 354
  • 1
  • 4
  • 16
  • Until you have a domain or a virtual host, I would recommend you to use `php artisan serve` on local and browse at http://localhost:8080 I do **not** recommend to modify index.php or .htaccess – Clément Baconnier Apr 10 '19 at 06:46
  • But I think best practice is to create api is should be without port? Am I correct or incorrect ? – Mohammed Sabir Apr 10 '19 at 06:48
  • Does it matter when you work on localhost? If so you can still configure a virtualhost – Clément Baconnier Apr 10 '19 at 06:49
  • I switched the things from localhost to another server with some IP like above so I think its giving issue due that that only. Because on localhost it was working without any issue – Mohammed Sabir Apr 10 '19 at 06:51
  • Here's one of the right way to access from another server https://stackoverflow.com/a/30675683/8068675 And again, I do **NOT** recommend to modify/move index.php or .htaccess – Clément Baconnier Apr 10 '19 at 07:03
  • @MohammedSabir First undo all changes that you did. Second, do you know how to create a virtual host on your machine? – nice_dev Apr 10 '19 at 07:05

2 Answers2

0

You rename server.php but not recommend. This file copy then rename

0

Yes, if you have done those settings you will not be able to properly access on the localhost by running php artisan serve. So for this, you can install xampp and do the virtual host settings. Check more info at

How to enable Virtual Host on Xampp for Laravel?.

On the benefit of this is that you don't have to run the php artisan serve command again and again.

Hussain Abid
  • 111
  • 1
  • 8