Hello everyone just wondering how to get the exact path of a certain url removing the files or parameter e.g. url = http://forums.digitalpoint.com?1937423i result = http://forums.digitalpoint.com url = http://site.com/folder/files.html result = http://site.com/folder URL = htp://www.site.com/myfile.html result = http://www.site.com Thanks in advance for any help
U can do lyke this ! 1 : create in ur root directori a file named .htaccess 2 : add this code : Options +FollowSymLinks RewriteEngine On RewriteRule ^index.html index.php RewriteRule ^add.html test.php?id=12122121 RewriteRule ^go/ test.php?id=11 Code (markup): Options +FollowSymLinks RewriteEngine On RewriteRule ^index.html index.php //index.php is original url and rezult url is index.html RewriteRule ^go/ test.php?id=11 from "test.php?id=11" original url the rezult will be as a folder ...! is simple to use if u need mre help post or pm !
try this example on a seperate file, it will show you all the values you need: <pre><?php print_r($_SERVER) ?></pre> PHP: The variable you'll be interested in is $_SERVER['HTTP_HOST'] ----------------------------------- ----------------------------------- Sorry, here's what you're looking for: <?php $url = "http://www.example.com/directory/script?get1=value1"; $parsed_url = parse_url($url); ?> <pre><?php print_r($parsed_url); ?></pre> PHP: the output: Array ( [scheme] => http [host] => www.example.com [path] => /directory/script [query] => get1=value1 ) Code (markup): so the value you're interested in is $parsed_url['host']
hello maybe this help <?php echo('http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['REQUEST_URI']).''); ?> PHP:
The thread owner I think asked about manipulation not mod-rewrite. so, pinoy, you need to use PHP's eregi_replace(), and some Regular Expression to deal with this. Good luck,
Yes you're right I need to manipulate the url, for example I have site where webmasters can submit a url , instead of getting the entire url including file and parameters. meaning remove all files or parameter in the url http://www.site.com/?parameter remove the /?parameter - http://www.site.com or http://www.site.com/folder/file.php remove /file.php - http://www.site.com/folder
$url = "http://www.site.com/?parameter"; $host = substr($url,0,strpos($url,"/")); Code (markup): result http://www.site.com/ $url = "http://www.site.com/folder/file.php"; $host = substr($url,0,strpos($url,"/")); Code (markup): result http://www.site.com/folder/ if you dont want the / on the end do $url = "http://www.site.com/folder/file.php"; $host = substr($url,0,strpos($url,"/")-1); Code (markup): result http://www.site.com/folder/ Untested, but should work in theory.