I am new to apaches rewrite_mod and i have read plenty of tutorials which explain how you can rewrite Clean Urls for search engines... Now I think i get it But I am toatally confused.
Now for instance i have a url
--------------------------
----------
----------
----------
------
http://www.server.com/index.php?var=1&var=2--------------------------
----------
----------
----------
------
Now i would like to rewrite this url as
--------------------------
----------
----------
----------
------
http://www.server.com/index.php/1/2--------------------------
----------
----------
----------
------
using Apaches .htaccess files i can use
<Files index>
ForceType application/x-httpd-php
</Files>
where i can rename index.php to index and it will still be interpeted as a PHP script
so now i have
--------------------------
----------
----------
----------
------
http://www.server.com/index/1/2--------------------------
----------
----------
----------
------
Supossingly apache has reads a URL backwards using some sought of look back function
so when i call
--------------------------
----------
----------
----------
------
http://www.server.com/index/1/2--------------------------
----------
----------
----------
------
apache will see
2 is not a dir --then--
1 is not a dir --then--
apache will see /index/ and know its a php script to execute.
and in the index file you can use
$var_array=explode("/",$PA
TH_INFO);
$var_array[0]=2
$var_array[0]=1
and you can use thes vars to query a database??
Well Thats the way it is supposed to work ----- well it not for me
--------------------------
----------
----------
----------
---------
::: THE PROBLEM:::
I have read a nice tutorial at zend.com about what im trying to accomplish
http://www.zend.com/zend/spotlight/searchengine.php-----------------------
Now they have a fuction that will place the $PATH_INFO into vars for you
--------------------------
----------
----------
-
if(isset($PATH_INFO)) {
$vardata = explode('/', $PATH_INFO);
$num_param = count($vardata);
if($num_param % 2 == 0) {
$vardata[] = '';
$num_param++;
}
for(var $i = 1; $i < $num_param; $i += 2) {
$$vardata[$i] = $vardata[$i+1];
}
}
?>
--------------------------
----------
----------
-
Now with this in mind we take the (index.php) renamed to index
and place the above code in there
Now we go call and call
--------------------------
----------
----------
----------
------
http://www.server.com/index/1/2--------------------------
----------
----------
----------
------
Now apache should see no 2/ or /1/
but it should execute index
now according to the $PATH_INFO it should contain /1/2
and when it sees index it should seperate them into
$$vardata[0]=2
$$vardata[1]=1
This is not the case as soon as i call
--------------------------
----------
----------
----------
------
http://www.server.com/index/1/2--------------------------
----------
----------
----------
------
I recive an 404 error, so the apache indian aint looking for its ancestors get me??
Any help would be much much much appreciated.
Thank you
Sonny