I have a problem with url in Laravel
<td> Website: {{$data[0]->internet}}</td>
where internet is some website name, for example www.foo.com
The problem is that output URL is http://localhost/www.foo.com instead of http://www.foo.com
change the target attribute target="blank" to target="_blank"
Change your html to
{{$data[0]->internet}}
As stated in the Laravel documentation: https://laravel.com/docs/5.7/urls
The url helper may be used to generate arbitrary URLs for your
application. The generated URL will automatically use the scheme (HTTP
or HTTPS) and host from the current request
$post = App\Post::find(1);
echo url("/posts/{$post->id}");
// http://example.com/posts/1
In your case you won't need the url helper function.
Also make use of the http or https protocol in this format:
http://www.foo.com or https://www.foo.com to make an absolute url instead of a relative one.
Try this way:
{{$data[0]->internet}}
If your variable internet is some website name, for example
www.foo.com and you need to link this URl in anchor tag you dont need
to call this variable inside url() function you can simply use that
variable to link the url in anchor tag.
If you want to get the base URL of your site then you can use url()
fucntion which return base url of your website.
Just replace below line with your code
<td>
Website:
{{$data[0]->internet}}
</td>
Related
Good Day! I've got some trouble on PHP. If I click an href which is this <a href = 'members/loans/loan-application-form.php'> it goes to the loan-applicaton-form.php, but if i click it again inside the loan-application-form.php (cuz it is located at the navbar that exist in all pages) the href of the anchor concatenates on the existing url and it creates an error telling that address is not existing. I already knew that the problem is it searches the address on the current directory and probably it will return an error because there is no existing address on the directory because it is the origin or the parent. What is the best way to avoid this?
Add a base tag to your header. This will prepend all HTML URL's with the given base URL. (Including images, CSS and JS calls)
<head>
<base href="http://www.yourdefaulturl.com/">
</head>
Your URL will then be http://www.yourdefaulturl.com/members/loans/loan-application-form.php
You can use an absolute path
<a href = 'http//your.site.cpm/members/loans/loan-application-form.php'>
Advice : you can read this article
or this stack question
Or you can use ../ to navigate inside your relative path
Lets imagine your nav bar is located at /navigation/navbar.html
Then you can have a relative path like
<a href = '../members/loans/loan-application-form.php'>
By specifying relative Urls like so:
<a href = 'members/loans/loan-application-form.php'>
You are simply stating you wish to go form the current page to this page, hence why it is being added to the end of the current URL. The best way to avoid this quite simply is to set an absolute URL like so:
<a href = 'http://projectname/members/loans/loan-application-form.php'>
Even when not using http:// it is often still considered relative so be sure to include this.
Another way to do the same but slightly quicker would be to add a variable in say your header file for example:
$url = 'http://example.com';
Then when specifying the URLs you can do say:
<a href = '<?php echo $url;?>/members/loans/loan-application-form.php'>
This just means that should you say change your domain, rather than editing every URL you can simply edit the variable value and be done with it.
I am new to CodeIgniter and having trouble with link formation. In my page, I have a link to another page set to:
<li>Feed Page</li>
Here the feed is one of my controllers, but the link is showing as:
http://localhost/BusinessPad/localhost/BusinessPad/feed,
which doesn't actually exist. I can't understand how this happened; I have made sure: $config['index_page'] = ''; and I added an .htaccess file. If I leave $config['base_url']='', the base URL is still not working for me.
To deal with anchor tag, You can have like this
Feeds
You shall put the base_url inside your anchor tag and then your controller name.
Then you will get the url like localhost/BusinessPad/feed which you expect.
Note : Make sure you have loaded the url helper by $this->load->helper('url'); or loaded in autoload itself
Feed Page
if this not works use this
Feed Page
Explain :
<?php echo base_url();?>//URL
BusinessPad//Controller
feed//Function
in 1. this will give your site URL. http://localhost/BusinessPad/localhost/. if you host this to live server it will come with tour domain name.
then in 2 it will call your controller which Contains your functions.
Note: if you juct call your controller it will call automatically public function index() if you create.
then in 3 it will redirect to your function which you exactly need.
i'm having an problem with the URL of Codeigniter.
When i use one controller with parameter, example: localhost/ci/products/news (where localhost/ci is the url base), after i click in any element <a />, example: <a href="home"/> Codeigniter redirects for localhost/ci/products/home and no for localhost/ci/home.
Anyone know why this happens?
You must use a base_url for links. Right now your anchor has a relative path in the href="home", you should have full path in your links, when u use mod_rewrite for nice urls.
like
Home
I have the following link:
<li>Dogs</li>
In my config.php I have:
$config['base_url'] = '127.0.0.1/Won/';
And when I go to link on that link above, it points to this:
http://127.0.0.1/Won/127.0.0.1/Won//gallery/dogs
Yes I have tried to search for a solution to this prior to asking.
Your base url is set as:
127.0.0.1/Won/
Your html anchor uses this code for the href:
<?php echo base_url() ?>/gallery/dogs
If you inspect the DOM using your browsers developer tools you should see that your href is being set as:
127.0.0.1/Won//gallery/dogs
To solve this you need to change your configs base url to the following:
http://127.0.0.1/Won/
You also need to remove the extra forward slash from your anchors href code. The correct code would be:
<li>Dogs</li>
How can I stop Wordpress from appending a URL and instead go to an absolute one?
By this, I mean I have a form which posts to a php page, and in the action parameter I have
action="www.oursite.com/feedbackpage/"
( I have also tried just feedbackpage/), but Wordpress always just appends it to the current URL (so it would be http://www.oursite.com/pagewithform/www.oursite.com/feedbackpage/)
How do I get wordpress to redirect the user to an absolute URL?
You need to make sure you either hardcode the http:// or set it to a proper relative path (so http://www.oursite.com/feedbackpage or /feedbackpage/).
Without the http:// your link is being treated as relative so it is looking for the 'www.oursite.com' folder in the current folder 'feedbackpage'.