Yalcin Yalcin - 5 months ago 16
PHP Question

Changing base url of localhost

I am learning PHP and Laravel. Until now I always implemented frontend and never had to do backend and never had to configure apache. I think my problem is a very easy one but I didn't know how to fix, because I didnt know what keyword I should search for.

My problem:

I am implementing two projects. One is called LearningLaravel and the other one is called MyFirstPHPage. In both projects I am using Laravel for backend, Angularjs for frontend and XAMPP for apache.

My problem is that I want to change the base url of both pages.

For example when I want to show the settings view of the first project I have to go to the url


localhost/LearningLaravel/resources/views/welcome.blade.php#/settings


and for the second page to


localhost/MyFirstPHPage/resources/views/welcome.blade.php#/settings


But I only want to type something like


localhost/LearningLaravel/#/settings


or


localhost:8000/settings


for the settings of the first project and


localhost/MyFirstPHPage/#/settings


or


localhost:8080/settings


for the second project. How can I achieve this? Links to tutorials would be ok too.

Thanks in advance

Answer

Create virtual host for Laravel project:

<VirtualHost some.app:80>
    DocumentRoot "C:/LaravelProject/public"
    ServerName some.app
    ServerAlias some.app

    <Directory "C:/LaravelProject/public">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Then add to Windows hosts file something like this:

localhost    some.app

Restart Apache and use http://some.app/settings instead of localhost/MyFirstPHPage/resources/views/welcome.blade.php#/settings