Advertisement

Link takes me to localhost

General questions relating to Joomla! 5.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
Blackton
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Mon Feb 17, 2025 4:20 am

Link takes me to localhost

Post by Blackton » Mon Mar 10, 2025 6:42 pm

Sorry if this issue is already address somewhere, but I'm not even sure what to look up about this or what to call it. I set a link on my size logo that supposed to take me back to home, and I just set it as "/" I thought this would be relative to the current location, and it appears to be so when I test it on the host machine. However, as soon as I try to click the link on a different machine, it seems to assume that the current position is "localhost" (which it DOES happen to be when run from the server). However, I didn't hard code "localhost" into the link, so I'm not sure why it's trying to base the relative location on that. Does anyone know what the right way is to get the link to just take me back to the home page? Thank you!

Advertisement
User avatar
ceford
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3091
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: Link takes me to localhost

Post by ceford » Mon Mar 10, 2025 7:34 pm

I don't quite understand how/where you set the link. Could you provide your site url so we can have a look?

Blackton
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Mon Feb 17, 2025 4:20 am

Re: Link takes me to localhost

Post by Blackton » Mon Mar 10, 2025 9:14 pm

I set the link inside of the Joomla admin area for my site. I just right clicked the image in the Module editor and added a link, and put "/" as the link. However, I went back later to check it and it had changed it to "../" I changed it back to just "/" Then just now I decided to check "inspect element" on the site, and it showed "localhost" in the link! I went back into the admin panel to check it there, and it's showing with "localhost" in the path there as well! How is it just randomly changing the links that I explicitly set?! This is very weird to me!

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 31667
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: Link takes me to localhost

Post by Per Yngve Berg » Tue Mar 11, 2025 5:53 am

"localhost' is the host name. It will correct itself when transfered to a proper host with a domain name.

Blackton
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Mon Feb 17, 2025 4:20 am

Re: Link takes me to localhost

Post by Blackton » Wed Mar 12, 2025 12:24 am

So why is it not correcting itself? All of the other menu items are transferring properly, so I know my dns is working correctly and that my server is working. But just that one logo link keeps trying to access localhost, which doesn't have anything there on the client machine.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44993
Joined: Sat Apr 05, 2008 9:58 pm

Re: Link takes me to localhost

Post by Webdongle » Wed Mar 12, 2025 1:42 am

Blackton wrote: Mon Mar 10, 2025 6:42 pm ... I just set it as "/" I thought this would be relative to the current location, and it appears to be so when I test it on the host machine. However, as soon as I try to click the link on a different machine, it seems to assume that the current position is "localhost" (which it DOES happen to be when run from the server). ...
On localhost the root is localhost, which is one folder above the Joomla folder.
On localhost you can create an alias. Normally you would type in the browser
localhost/thenameofthejoomlafolder

But if you set an alias then you would just type thenameofthejoomlafolder
That is because of the alias
localhost/thenameofthejoomlafolder would become the root
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

Blackton
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Mon Feb 17, 2025 4:20 am

Re: Link takes me to localhost

Post by Blackton » Wed Mar 12, 2025 3:41 am

Yes, but why would I want it to go to localhost when there is nothing there? That would only make sense if it was trying to follow that link from on the host machine. Anywhere else that would make it point to the client machine and fail to load anything. Shouldn't the relative path on the client machine just be the domain name for the site that you entered (which would resolve through the DNS to the actual host machine, no the client machine)?

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44993
Joined: Sat Apr 05, 2008 9:58 pm

Re: Link takes me to localhost

Post by Webdongle » Wed Mar 12, 2025 4:32 am

The machine that takes you to
localhost/thenameofthejoomlafolder will have an alias set up.

There is nothing wrong with the way Joomla is working. The problem is there is no alias set up on the machine where it takes you to localhost
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

Blackton
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Mon Feb 17, 2025 4:20 am

Re: Link takes me to localhost

Post by Blackton » Wed Mar 12, 2025 5:49 am

Well all the other links seem to work properly though, just not this one. I did notice that my other links all have "index.php" in them, so I tried adding that to the logo link. In so doing, I undid the "localhost" change that it keeps changing my link address to, and now it seems to work...at least until it changes it back to "localhost" again without asking!

I would like it to not show index.php in every url though. I assume I must have an alias set up already, because I don't see the root site folder in the address bar, but I would like to not see "index.php" either. Is there a place where I can see where any aliases are set so I can change to include the index.php part as well? Thanks for the help!

User avatar
ceford
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3091
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: Link takes me to localhost

Post by ceford » Wed Mar 12, 2025 8:39 am

ceford wrote: Mon Mar 10, 2025 7:34 pm Could you provide your site url so we can have a look?

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 31667
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: Link takes me to localhost

Post by Per Yngve Berg » Wed Mar 12, 2025 8:39 am


Blackton
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Mon Feb 17, 2025 4:20 am

Re: Link takes me to localhost

Post by Blackton » Thu Mar 13, 2025 4:00 am

OK, I tried following tutorial, but I'm not sure what "virtual host configuration file" refers to, and I also couldn't find "httpd.conf" anywhere on my filesystem, so I'm not sure if my system is allowing .htaccess overriding or not, but I followed all the other steps and it didn't work, so I suppose that could be the problem. Any idea where to look for that "virtual host configuration file, so I can see if that is the problem?" Thanks!

Blackton
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Mon Feb 17, 2025 4:20 am

Re: Link takes me to localhost

Post by Blackton » Thu Mar 13, 2025 4:18 am

ceford wrote: Wed Mar 12, 2025 8:39 am
ceford wrote: Mon Mar 10, 2025 7:34 pm Could you provide your site url so we can have a look?
I wouldn't mind, but would like to get https working before posting it on a public forum, if that makes any sense. I'm still not sure what the issue is with trying to access the site by https rather than http...

Mr. Wimpy
Joomla! Guru
Joomla! Guru
Posts: 620
Joined: Fri Dec 02, 2005 10:46 am
Location: The Netherlands

Re: Link takes me to localhost

Post by Mr. Wimpy » Thu Mar 13, 2025 9:47 am

Webdongle already explained it a little bit...

You need to take 2 things in consideration:
1 The main root (is there a better word?): holds all the (public facing) website files
I.e. localhost, or example.com

2 Joomla root: the location/folder that holds the Joomla files
I.e. localhost/my-joomla, or example.com/my-joomla

Joomla files can be located in the main root. Then the main root is the Joomla root.

What does a link to "/" do?
It's a link to the main root. So to localhost/ or example.com/
That is how html works.

Why do all other links work correctly?
All links created through Joomla take the Joomla root into consideration and will automatically add it to the link.
If the Joomla root is example.com/my-joomla, then Joomla creates the link /my-joomla/joomla-link
If the Joomla root is example.com, then Joomla creates the link /joomla-link

But why doesn't Joomla add the Joomla root to my "/"?
In html "/" is the main root, the starting point.
Your website/html does not know whether you want to go to the main root (start) or the Joomla root.

How to solve this?
- Create a link to the default menu-item instead of entering "/": Both TinyMCE and JCE have that option
- Or enter the default menu-item link yourself, usually it's index.php?Itemid=101

Blackton
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Mon Feb 17, 2025 4:20 am

Re: Link takes me to localhost

Post by Blackton » Thu Mar 13, 2025 10:16 pm

Yes, that all makes sense to me, but that's not what Joomla keeps doing. It changes my link from "/" to "localhost." I'm not disagreeing about it interpreting "/" into either "myexample.com" or "localhost," but it's NOT "/", it's "localhost!" I keep changing the link back to "/" but when I check it again, Joomla has always changed it back to "localhost" (which is NOT "/" and therefore will not interpret to "myexample.com" on the client). It wasn't until I changed it to "/index.php" that it stopped changing what I had entered. I guess the other links were working because they were handled by Joomla's article interface, which was automatically adding "index.php" to all of those to make them work.

So the logo link works properly now that it has stopped changing it from "/" to "localhost." But I would like to be able to not have index.php appear in ANY of my URLs, including the URLs that are coming from the articles. I remember when I had worked with Express years ago that it had a route table to interpret all of the URLs however you wanted. Is there some way to do something like that in Joomla, like to get it to interpret "/" as "[main root]/index.php/" instead of just "[main root]"? Thank you!

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44993
Joined: Sat Apr 05, 2008 9:58 pm

Re: Link takes me to localhost

Post by Webdongle » Thu Mar 13, 2025 11:15 pm

On your localhost create an 'alias' to the folder Joomla is in then see https://docs.joomla.org/Enabling_Search ... EF%29_URLs
Or just put it on the Host server and follow the instructions on the page linked to.

What localhost are you using?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

Blackton
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Mon Feb 17, 2025 4:20 am

Re: Link takes me to localhost

Post by Blackton » Fri Mar 14, 2025 2:51 am

Webdongle wrote: Thu Mar 13, 2025 11:15 pm On your localhost create an 'alias' to the folder Joomla is in then see https://docs.joomla.org/Enabling_Search ... EF%29_URLs
Or just put it on the Host server and follow the instructions on the page linked to.

What localhost are you using?
Yes, those were the instructions I was originally trying to follow, but I had mentioned that I don't know what "virtual host configuration file" refers to, and I also couldn't find "httpd.conf" anywhere on my filesystem.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44993
Joined: Sat Apr 05, 2008 9:58 pm

Re: Link takes me to localhost

Post by Webdongle » Fri Mar 14, 2025 11:40 am

What localhost are you using?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 31667
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: Link takes me to localhost

Post by Per Yngve Berg » Fri Mar 14, 2025 12:31 pm

Search for apache.conf

Advertisement

Post Reply

Return to “General Questions/New to Joomla! 5.x”