php get url of redirect from source url

Thanks to @king-isaac the following code was tested and it works. <?php $url=”http://libero-news.it.feedsportal.com/c/34068/f/618095/s/2e34796f/l/0L0Sliberoquotidiano0Bit0Cnews0C12735670CI0Esaggi0Eper0Ele0Eriforme0Ecostituzionali0EChiaccherano0Ee0Eascoltano0Bhtml/story01.htm”; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Must be set to true so that PHP follows any “Location:” header curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $a = curl_exec($ch); // $a will contain all headers $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); // … Read more

How to redirect a URL in Nginx

Best way to do what you want is to add another server block: server { #implemented by default, change if you need different ip or port #listen *:80 | *:8000; server_name test.com; return 301 $scheme://www.test.com$request_uri; } And edit your main server block server_name variable as following: server_name www.test.com; Important: New server block is the right … Read more

Rewriting an arbitrary number of path segments to query parameters

First of all: You shouldn’t use .* if you can be more specific, like in this case [^/]+. Because multiple .* can cause immense backtracking. So: RewriteRule ^viewshoplatest/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ /viewshoplatest.php?$1=$2&$3=$4&$5=$6&$7=$8&$9=$10&$11=$12&$13=$14&$15=$16 You can use a took like RegexBuddy to see the difference in how these regular expressions are processed. But since mod_rewrite does only allow to reference … Read more