Forum Moderators: coopster
I have my site hosted with an Apache virtual server. Now I want to use URL Rewriting but there is no mod_rewrite module installed on my server. I told to my host to do so, but they replied that its very difficult to recompile Apache with mod_rewrite module.
So I searched some script for it & I got some solution on the net. Here is the code of PHP Script & .htaccess file, but it is not working. Can somebody tell me what is wrong in it.
//// PHP Code (file name is article without any extension)///////
processURI():
// Takes the query string and extracts the vars by splitting on the '/'
// Returns an array $url_array containing keys argN for each variable.
function processURI() {
global $REQUEST_URI; // Define our global variables
$array = explode("/",$REQUEST_URI);// Explode the URI using '/'.
$num = count($array);// How many items in the array?
$url_array = array();// Init our new array
for ($i = 1 ; $i < $num ; $i++) {
$url_array["arg".$i] = $array[$i];
}
// Insert each element from the
// request URI into $url_array
// with a key of argN. We start $i
// at 1 because exploding the URI
// gives us an empty ref in $array[0]
// It's a hacky way of getting round it
// *:)
return $url_array; // return our new shiny array
}
//// .htaccess file /////
<Files article>
ForceType application/x-httpd-php
</Files>
Looking for help
Navin
$dirname = getenv("REQUEST_URI");
if (substr($dirname,-1,1)!= "/") {
$dirname = $dirname."/";
}
$dirname = split("/", $dirname);
$region = $dirname[sizeof($dirname) - 2];
if ($region == "region") {
header("Location: /");
}
with .htaccess like
<Files region>
ForceType application/x-httpd-php
</Files>
I run Apache 2 on my test server and had to add
acceptpathinfo on
to .htaccess to get it to run the script.