i am trying to make the URL in my PHP application cleaner using htaccess. Earlier the links of my application were in this format
http://localhost/25_2_april/video.php?cat_id=2&category=Programming-Language, but with the help of htaccess i was able to convert it into
http://localhost/25_2_april/video-library/2/Programming-Language. Now ,the question is that every time i run my application it loads the messy URL instead of the clean URL , although when i edit the url ,and make it clean url, then that works too. Now is there any way, that it directly loads the clean url instead of the messy url.
Below is the anchor tag through which i am calling this particular page.
<a href="<?php echo 'video.php?cat_id='.$cat_id.'&category='.$cat_name; ?>">
As you are adding static URL in html so must have to pass your clean URL as :
<a href="<?php echo 'http://localhost/25_2_april/video-library/'.$cat_id.'/'.$cat_name; ">
Related
I have a php documents in which is used a MainUrl to get the url. The thing is that the main url is HTTP. Is there a way to change it to HTTPS? Thank you
Im using codes like this
<img src="<?php echo MAIN_URL; ?>/img/adv-img.png">
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.
Let I am in following location
http://localhost/ignitershop/index.php/seller_controller/viewcart
And here in this view I have a link and using it i want to move to another method of the same controller called removeRow() . So I am using href as below
<a href="seller_controller/removeRow" >CLICK TO REMOVE </a>
So I expect the new url to be :
http://localhost/ignitershop/index.php/seller_controller/removeRow
but the url seems to be concatenating. And it is becoming something as below :
http://localhost/ignitershop/index.php/seller_controller/seller_controller/removeRow
That is seller_controller is coming twice. I am facing such type of concatening problem using redirect also. So I need to know what it is the best way for switching method of the same controller. Any good solution ???
Try like
<a href="<?php echo site_url('seller_controller/removeRow');?>" >CLICK TO REMOVE </a>
Or you can also try like
<a href="<?php echo site_url().'seller_controller/removeRow';?>" >CLICK TO REMOVE </a>
You cont use base_url() Because it doesnt included the index page (May be the index.php ) where site_url() has the combination with base_url() and index url.
Use ob_start(); at the begging of the script.
This is happening, because your link is relative - i.e. it is added to the current URI minus the last part. Think of it like directories and files - the last part (viewcart) is a file, and the rest is a directory. A relative link means "Hey, take me to this file (removeRow), but start delving from the current directory".
This means that if you have http://localhost/ignitershop/index.php/seller_controller/viewcart and there you visit a link with content Link, it will send you to http://localhost/ignitershop/index.php/seller_controller/one/two/three
To fix it, use base_url() or site_url() functions from the URL helper accordingly, which will do the job for you. Check out the documentation for more info.
Try to use the absolute path by using either site_url() or base_url()
I am trying to formulate a link to another page in my directory. It can either be done in the php code or the html. However for some strange reason, and only on this page, everytime i generate a url to a new page, the url generated is the page i am on + the url i want to go to.
For example, if i am on mysite.php and formulate a link to go to purchase.php then the generated url is mysite.php/purchase.php
Does anyone know why this might be?
<h1>Success</h1>
Link text
<?php
...
...
?>
this is essentially all i have with an echo saying hi! . What happens is, if i am currently on home.php the above url becomes path/home.php/page.php
You should create url for /purchase.php instead of purchase.php.
You can read more about what's the difference in here.
Hello I am trying to figure out how to make it so when someone clicks a link on my search results it will open in a new window and in the new window have an iframe that displays the url. I am not sure how to go about doing this. I have
$row['url']
that displays the url for each result to use.
To be more specific I am trying to do what filestube does. I like the feature a lot and would like to use something like it on my site. Here is an example url to show you want I mean http://www.filestube.com/5a4c10249bd9fce003e9/go.html
when the link is clicked on filestube it will open a page like this. I have seen lots of sites do this but filestube is what pops in my head right now. Can anyone provide me with a code example or try to explain how to do this? thanks.
You need to redirect to a URL inside of your application, example my_url.php and post to it in parameters the URL you want to show. Than in that script, load an iFrame with that URL.
Example of my_url.php?url=http://www.google.ca:
<div>You Header</div>
<iframe src="<?php $_GET['url']"></iframe>
<div>Your Footer</div>
The link should point to another PHP page. Something like this.
http://www.google.com
In your open-link.php, write your iframe code.
<iframe src="<?=$_GET['url']?>"></iframe>
Assuming you have PHP file named external.php
Make that PHP file accept a $_GET parameter.
Pass the URL as a param
Use that URL to point the iframe in that PHP file to whatever URL is passed