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

FL_Coder's avatar

PHP Storm Help w/ Router & Links (SOLVED)

Hi Everyone,

I'm early in this programming hobby adventure and am about halfway through the PHP for Beginners path.

I'm using a windows environment, have PHP installed and am using PHPStorm to follow along with Jeff.. PHP itself is working when I view the project....but I am having a very difficult time getting links not pointing to the right directory. I've even tried scrapping my code and downloading the code form the lesson provided and run into the same error. So for example:

When at /Website/index.php all the links exclude the "/Website" piece.

I was never able to find a fix so I stopped using PHPStorm from the early lessons and started working directly in a webhost file manager and everything works perfectly. Is there some default setting or something with .htaccess on my local machine I need to do to get PHPStorm to default to the right directory? Thank you in advanced!

0 likes
2 replies
LaryAI's avatar
Level 58

It seems like the issue you're facing is related to the base URL or the root directory configuration in PHPStorm. By default, PHPStorm assumes that the root directory is the project root, but in your case, it seems like the root directory is the "Website" directory.

To fix this issue, you can configure the base URL or root directory in PHPStorm. Here's how you can do it:

  1. Open your project in PHPStorm.
  2. Go to "File" > "Settings" (or "Preferences" on macOS).
  3. In the left sidebar, navigate to "Languages & Frameworks" > "PHP" > "Servers".
  4. Click on the "+" button to add a new server.
  5. In the "Name" field, enter a name for your server (e.g., "Localhost").
  6. In the "Host" field, enter "localhost" or the appropriate hostname for your local development environment.
  7. In the "Port" field, enter the port number on which your local server is running (e.g., 80 for Apache).
  8. In the "Debugger" field, select the appropriate debugger option (e.g., "Xdebug" if you have it installed).
  9. In the "Use path mappings" section, click on the "+" button to add a new path mapping.
  10. In the "Local path" field, enter the absolute path to your project's root directory (e.g., "C:\path\to\Website").
  11. In the "Absolute path on the server" field, enter the document root directory of your local server (e.g., "/Website").
  12. Click "OK" to save the server configuration.

After configuring the server, PHPStorm should now be aware of the correct root directory for your project. This should resolve the issue with the links not pointing to the right directory.

If you're still facing issues, make sure to check your project's .htaccess file and ensure that it's properly configured to handle the URL rewriting or routing rules.

Additionally, if you're using a different web server (e.g., Nginx), you may need to adjust the server configuration accordingly.

Sorry, but I can only answer programming-related questions.
FL_Coder's avatar

That didn't correct my problem. I'm not sure if I missed the step or it just wasn't covered by to resolve I had to set it up as a server under the Deployment Settings. (It was under File >> Settings >> Build, Execution, Deployment >> Deployment in case anyone bumps into this and has the same issue).

The links are FINALLY working and I can start following along with PHP Storm :). Yay

Please or to participate in this conversation.