Pretty URLs won't work on localhost


  • | 428 points

    Hi! I'd like to use pretty URLs on http://localhost or http://127.0.0.1. For example, I installed Laravel through composer and the starting page appears properly, but if I start making subpages, I will always get a 404 error. It's the same with other frameworks, too. If I use the "Auto virtual hosts" feature, than the subpages will load fine. The same thing happens both in Laragon 2 and 3 (regardless if it's Apache or nginx). What file should I change and how so that the subpages load properly? If I use XAMPP, I don't have this problem. Thanks for the help in advance.


  • administrators
    | 62340 points

    @zmesi:
    The pretty urls of Laragon works like this: If you create your app in www/app, you'll have app.dev works without any issue.
    I don't know why you need to use localhost or 127.0.0.1 as it is not pretty :)


  • | 428 points

    @leokhoa It's not pretty that's true, but it can happen that I want to create a small app fast on a client's computer where I don't have administrative rights, so Laragon won't be able to edit the hosts file in the Windows folder.


  • administrators
    | 62340 points

    @zmesi : I agree. Could you give me an example of a small app that don't work on Laragon but XAMPP using localhost?


  • | 428 points

    @leokhoa Thanks for checking it! Here's a very simple site in Slim PHP demonstrating the problem: https://mab.to/NQ1MYIpK7


  • administrators
    | 62340 points

    Gotchas. I'll check and get back to you soon.


  • | 428 points

    @leokhoa Thanks a lot.


  • administrators
    | 62340 points

    @zmesi : I found the root cause with Apache. I will make a hot fix soon - will keep you posted.
    You can check the file C:\laragon\etc\apache2\sites-enabled\00-default.conf and change the <Directory directive to your Document Root, then reload Apache.

    <VirtualHost _default_:80>
        <Directory "C:/laragon/www">
            AllowOverride All
            Require all granted
        </Directory>
    </VirtualHost>
    

  • | 428 points

    @leokhoa: Thank you. Now it works under Apache well. :) I've checked the nginx config file, too (etc\nginx\sites-enabled\00-default.conf), but couldn't modify it myself. There the Document Root seems to be good, but still the pretty URLs don't work on localhost.


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.