Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

martin_k's avatar

Wrong URL

I have all the time the same problem.

I have a virtual host syworkx.local with xampp. When I put syworkx.local or localhost in chrome everything works great. There is a login panel. I put login and password and I am redirect to https://localhost/dashboard/. But the right url is https://syworkx.local/dashboard/. What is wrong?

I have many local domains in hosts and httpd-vhosts.conf. How can I setup all to work separately?

Thanks for the help. Martin

0 likes
27 replies
Nash's avatar

Is your APP_URL set to localhost in the .env file? Change it to the right url.

martin_k's avatar

But why I have no different when I put localhost or syworkx.local?

martin_k's avatar

There is my .env

APP_ENV=production APP_DEBUG=true APP_KEY=3wtKR5gTkgcpA9PGhEEm8Dx5ItVCMFtC APP_URL=localhost

Martin

martin_k's avatar

httpd-vhosts.conf:

<VirtualHost *:80> ServerAdmin [email protected] (here is my email address) DocumentRoot "C:/xampp/htdocs/syworkx/public/" ServerName syworkx.public ##ErrorLog "logs/dummy-host2.example.com-error.log" ##CustomLog "logs/dummy-host2.example.com-access.log" common

host:

127.0.0.1 localhost ::1 localhost 127.0.0.1 buchhaltung.local 127.0.0.1 manager.local 127.0.0.1 statistics.local 127.0.0.1 holidays.local 127.0.0.1 warehouse.local 127.0.0.1 rent-home24.com.local 127.0.0.1 www.rent-home24.com.local 127.0.0.1 prestashop.local 127.0.0.1 xdebug.local 127.0.0.1 blog.local 127.0.0.1 supply.local 127.0.0.1 usersmanagement.local 127.0.0.1 buchhaltung.local 127.0.0.1 ninja.local 127.0.0.1 cryptomator-vault 127.0.0.1 syworkx.local

Martin

munazzil's avatar

You have to use APP_URL=localhost as like below,

    APP_URL=127.0.0.1

and what you get when run below command in your CMD,

     php artisan serve
martin_k's avatar

I put your text, restarted xampp and next run command from powershell directly from syworkx directory but it made no chnge. Everything is the same.

Does Somebofy has a different idea?

ajithlal's avatar
<VirtualHost *:80>
     ServerAdmin [email protected]
     ServerName syworkx.public 
     DocumentRoot "C:/xampp/htdocs/syworkx/public/"
     <Directory "C:/xampp/htdocs/syworkx/public/">
         DirectoryIndex index.php
     </Directory>
 </VirtualHost>

can you rewrite it and check?

munazzil's avatar

Use below command to clear your caches,

php artisan cache:clear
php artisan route:clear
php artisan view:clear

In your app url as like keep,

    APP_URL=syworkx.local

can you show your config/app.php?

martin_k's avatar

I rewrite it, restarted xampp and no changed. Everything is the same.

martin_k's avatar

My config/app.php:

/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/

'url' => 'APP_URL',

Do you need all file or it is enough?

munazzil's avatar

You have to configure as like below,

    'url' => env('APP_URL', 'http://syworkx.local'),
martin_k's avatar

which is right?

<VirtualHost *:80> ServerAdmin [email protected] ServerName syworkx.public DocumentRoot "C:/xampp/htdocs/syworkx/public/" <Directory "C:/xampp/htdocs/syworkx/public/"> DirectoryIndex index.php

or

<VirtualHost *:80> ServerAdmin [email protected] ServerName syworkx.local DocumentRoot "C:/xampp/htdocs/syworkx/public/" <Directory "C:/xampp/htdocs/syworkx/public/"> DirectoryIndex index.php

martin_k's avatar

After: php artisan cache:clear php artisan route:clear php artisan view:clear

I put:

PS C:\xampp\htdocs\syworkx> php artisan serve Laravel development server started on http://localhost:8000/

munazzil's avatar

Can you marked as solved the others could able to find the answer check anyone reply right hand corner there are best answer button click on that.

martin_k's avatar

Ok, but the problem is not solved. My offline site doesn't work all the time.

I will put "best answer" when it will be solved.

Martin

martin_k's avatar

OK, but the problem is not solved all the time.

martin_k's avatar

I don't know why localhost and syworkx.local has the same result? Maybe here is the problem?

martin_k's avatar

Every laravel website open dashboard from localhost/dashboard not from from directory with project!!!!!

I know it is the problem but I can't find the solution for it. Online everything works very good.

Please help me!!!!

martin_k's avatar

I have many projects in \xampp\htdosc not only one.

I have many local domains. It is the reason why must be the different between local host and syworkx.local.

Martin

martin_k's avatar

xampp\htdocs\index.php

""<?php if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; header('Location: '.$uri.'/dashboard/'); exit; ?>""

Maybe there is a problem here?

Snapey's avatar

your virtual host settings need unique domain name, eg syworkx.local

app_url needs that same name

Access your site with this domain name. All requests turn up at the same web server and the server uses host headers to know which of your vhosts to use

Check what you have in redirect link

martin_k's avatar

I have in .env:

APP_ENV=production APP_DEBUG=true APP_KEY=3wtKR5gTkgcpA9PGhEEm8Dx5ItVCMFtC APP_URL=syworkx.local

but it doesn't work. I have the same when I type localhost and syworkx.local.

The homepage is ok but after login a have a dashboard from C:\xampp\htdocs\dashboard not from C:\xampp\htdocs\syworkx\resources\views\dashboard. How can I fix this redirection?

Please or to participate in this conversation.