PDA

View Full Version : mod_rewrite


Nightfire
12-31-2002, 10:41 AM
I'm trying to make a clients site 'search engine friendly' with the URL's, by having site.com/dir/page instead of site.com?page=xx

I've read that you have to edit the httpd.conf file in apache, but I don't have access to it on the host and being the crap host it is, I doubt they've got the rewrite ongine working. So, is there any other way to break a URL up and make a database query depending on the URL?

firepages
12-31-2002, 12:30 PM
you dont have to have mod_rewrite if you are happy with say...

site.com/index.php/var/var2

with the above url add this to index.php

<?
$my_get=explode('/',$_SERVER['PATH_INFO']);
print_r($my_get);
?>

then its a case of mapping the $my_get vars to your real vars etc.

depending on your server config & using apaches lookback feature you can sometimes do this..

site.com/pagename/var/var2

then apache looks back for the first file that matches a real filename, in this case pagename.php (or .htm or .html !!), just note that if you have a var.php/htm/html this method will fail.

also google the apache force-type directive or check it out in the apache documentation

Nightfire
12-31-2002, 07:37 PM
Thanks :) but after a few hours of emailing the host, they've turned mod_rewrite on for me :D