CodeIgniter Forums
In Codeigniter How to FILTER_SANITIZE_URL before redirect to new url - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: In Codeigniter How to FILTER_SANITIZE_URL before redirect to new url (/showthread.php?tid=68143)



In Codeigniter How to FILTER_SANITIZE_URL before redirect to new url - wolfgang1983 - 06-01-2017

When I click on my google button it sends me to the google links to verify user.

Code:
http://www.example.com/test/google?code=4/uxiEClMAV86scsrjARV-uMRgbypOu1MjT894sXgkAjc#


Once it has reached the link and user has been approved.

How can I use FILTER_SANITIZE_URL so it removes all illegal URL characters before I redirect to new page.

Currently still redirects to url http://localhost/project/# should be http://localhost/project/


PHP Code:
if ($this->input->get('code')) {

if (
$this->googleplus->getAuthenticate()) {

$redirect_uri 'http://' $_SERVER['HTTP_HOST'] . '/project/';

$test filter_var($redirect_uriFILTER_SANITIZE_URL);

redirect($test);

}




RE: In Codeigniter How to FILTER_SANITIZE_URL before redirect to new url - InsiteFX - 06-01-2017

Use one of php's trim methods like rtrim()


RE: In Codeigniter How to FILTER_SANITIZE_URL before redirect to new url - Paradinight - 06-01-2017

(06-01-2017, 02:48 AM)wolfgang1983 Wrote: When I click on my google button it sends me to the google links to verify user.

Code:
http://www.example.com/test/google?code=4/uxiEClMAV86scsrjARV-uMRgbypOu1MjT894sXgkAjc#


Once it has reached the link and user has been approved.

How can I use FILTER_SANITIZE_URL so it removes all illegal URL characters before I redirect to new page.

Currently still redirects to url http://localhost/project/# should be http://localhost/project/


PHP Code:
if ($this->input->get('code')) {

if (
$this->googleplus->getAuthenticate()) {

$redirect_uri 'http://' $_SERVER['HTTP_HOST'] . '/project/';

$test filter_var($redirect_uriFILTER_SANITIZE_URL);

redirect($test);

}


Remove the # from http://www.example.com/test/google?code=4/uxiEClMAV86scsrjARV-uMRgbypOu1MjT894sXgkAjc#


You can not remove the hash. It is not possible with php. If you redirect from url a to url b the browser add the same hash as the url a.

http://www.example.com/test/google?code=4/uxiEClMAV86scsrjARV-uMRgbypOu1MjT894sXgkAjc#
would be
http://www.example.com/project#

Example Script: https://forum.codeigniter.com/thread-68106-post-343729.html#pid343729

Do you understand me now?