Member Avatar for fatihpiristine

i forgot how to split urls :)

$url = "http://www.myhost.com/1,1,1,10.html";

i m trying to get 1,1,1,10.html n assign each value before commas to variables

any ideas??

Recommended Answers

All 6 Replies

<?php
$urloriginal = "http://www.mazur.com.ar/galeria/index.php?id=25";
echo "URL original: " . $urloriginal . "<br><br>\n";
$urloriginal = eregi_replace("http://", "", $urloriginal);
echo "URL original sin http//: " . $urloriginal . "<br><br>\n";
$parametros = stristr($urloriginal, "/");
echo "The request part: " . $parametros . "<br><br>\n";
$dominio = substr($urloriginal, 0, strpos($urloriginal, "/"));
echo "El dominio es: $dominio";
?>

ch.-

Member Avatar for fatihpiristine

i dont think you get the point.

i meant i wanna destroy this block: 0,0,1,1.html and assign each value to variable

Did you test my script?
You can obtain all the blocks that you want. With or wihtout some block.

ch.-

Member Avatar for fatihpiristine

yes i did.. but it s not the thing i want.
i will work on it

<?

// i add this part

$_SERVER['FULL_URL'] = 'http';
if($_SERVER['HTTPS']=='on'){$_SERVER['FULL_URL'] .=  's';}
$_SERVER['FULL_URL'] .=  '://';
if($_SERVER['SERVER_PORT']!='80') $_SERVER['FULL_URL'] .=  $_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME'];
else
$_SERVER['FULL_URL'] .=  $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
if($_SERVER['QUERY_STRING']>' '){$_SERVER['FULL_URL'] .=  '?'.$_SERVER['QUERY_STRING'];}
$url = $_SERVER['FULL_URL'];



$urloriginal = $url;
echo "URL original: " . $urloriginal . "<br><br>\n";
$urloriginal = eregi_replace("http://", "", $urloriginal);
echo "URL original sin http//: " . $urloriginal . "<br><br>\n";
$parametros = stristr($urloriginal, "/");
echo "The request part: " . $parametros . "<br><br>\n";
$dominio = substr($urloriginal, 0, strpos($urloriginal, "/"));
echo "El dominio es: $dominio";
?>
Member Avatar for fatihpiristine

tested and works ok..
another thing.. this is my url

http://www.blabla.com/en/category/25698

assignment:
language = en
category = category
id = 25698

sql does the query but when i redirect to this location i got 404 error.
how can i solve this?s

Member Avatar for fatihpiristine

i figured out. with htaccess file :)

RewriteEngine On

RewriteRule ^\.htaccess$ - [F] #to avoid accessing .htaccess files
RewriteRule ^\.jpg$ - [F] #jpg
RewriteRule ^\.html$ - [F] # htmls
RewriteRule ^\.css$ - [F] # css


RewriteRule ^([0-9]+),([0-9]+)$ /index.php?Language=$1&Index=$2 [L]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.