i want to pass a domain link with http or https protocol as parameter in the link
for example
http://www.payskip.me/url.php?go=https://www.oast.com
problem is when i pass the link without .com or any other extension it works well
like if i pass
http://www.payskip.me/url.php?go=https://www.oast.pk
its working but when i pass the link with .com its not working
example
http://www.payskip.me/url.php?go=https://www.oast.com
please tell me how can i solve this
URL encode the parameter, see reference:
http://www.payskip.me/url.php?go=https%3A%2F%2Fwww.oast.com
There is a url_encode function in php.
Related
I want to get the correct URL with PHP without any error, my links example:
https://example.com/
https://example.com/search/
https://example.com/search/?q=test
https://it.example.com/
https://it.example.com/search/
https://it.example.com/search/?q=test
so i want to get all link if is https://example.com/ show example.com if is https://example.com/search/ show example.com/search/ if is https://it.example.com/search/?q=test show example.com/search/?q=test etc.. without any error. thanks
Looks like you need $_SERVER['REQUEST_URI']:
$link = "$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
Have a look over the PHP documents too: http://php.net/manual/en/reserved.variables.server.php
This will return the HTTP Host without https, and will also get you the request_uri with query strings etc.
parse_url() will also give you each element, and then you can build up the string you need:
http://php.net/manual/en/function.parse-url.php
i have controller by name"job_classified" the problem is when i open
click me
in view it opens http://localhost/my_project/job_classified/google.com instead of google.com
what actually is the problem? i tried other code igniter URI functions but it didn't work for me.can someone guide me how to do it correctly
Why your code doesn't work is described here:- https://stackoverflow.com/a/2005097/4248328
So do like below:-
click me
try this
click me
Please change url to:
click me
Reason: HTML parses urls as of relative ones if no http or https is given.
HTML server in your case considers google.com as a relative file is the same directory.
In Codeigniter you can do it a couple of ways
Using the base_url from the url helper
Note: the base url in config.php must be set
https://www.codeigniter.com/user_guide/helpers/url_helper.html#base_url
Some Name
Some Name
Also you can use the anchor();
https://www.codeigniter.com/user_guide/helpers/url_helper.html#anchor
<?php echo anchor('job_classified', 'Job Classified');?>
<?php echo anchor('controller/function', 'Job Classified');?>
How to remove index.php from url
https://github.com/wolfgang1983/htaccess_for_codeigniter
Always prepend URLs with double slash. That way you don't need to think whether location should be http or https.
This way browser will automatically
determine which scheme to use
In Laravel the Redirect::to need a full link with http(s)://, In Jefrey shortener tutorial he used only full urls to test the app, even The url Validator passes only when given full urls.
Any other methods or other php function to use that redirect to urls without http(s)// ?
just use
Redirect::away('http(s)://')
Is there any way that I could I could have a parameter in the URL but not using question mark in PHP?
The inputted url as:
http://www.example.com/y/foo
But it actually parses as:
http://www.example.com/y/?y=foo
but the actual URL which the client has is the original URL.
The /y/ directory does exist and so does the index.php file inside of that.. But the /foo file does not exist.
This can be achieved via url rewriting. The url structure you are looking for will not be the actual url but it can replace the actual url and make your url look pretty, while the original url is responsible for the page being displayed.
The foo here is a parameter or supposedly argument for a function present on that page.
http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
I have my htaccess redirecting to a error404.php but I want that PHP file to be able to extract the original url parameters.
For example:
http://mywebsite.com/unknownfile.php?param1=value1¶m2=value2
I've tried $_GET['param1'] but that's empty. The $_SERVER['PHP_SELF'] just shows error404.php
Many thanks in advance.
You can access original URL via $_SERVER["REQUEST_URI"].
For example: requesting URL /hihi/meow?key=rumba which does not exists. The $_SERVER["REQUEST_URI"] will have that string, which you can parse with parse_url() function to split into parts and use other functions (like explode() to get to individual query strung parameters.
If you redirect this info will only be present in $_SERVER['HTTP_REFERER']