Forum Moderators: coopster
i've got this piece of code working already, which redirects
www.example.com/index.html
to
www.example.com/
function fix_index_url(){
if(preg_match('#(.*)index\.(html¦php)$#',$_SERVER['REQUEST_URI'],$captures)){
header('HTTP/1.1 301 Moved Permanently');
header('Location: '.$captures[1]);}
;}
fix_index_url(); (remember to replace the broken pipe!)
but now i'm trying to work out something that will get rid of all the file extensions as well. for example...
www.example.com/page.html
would redirect to
www.example.com/page
i know i could use something similar to the piece of code above, but for the life of me, i can't work out the preg_match expression to use. anyone help a poor guy out?
www.example.com/page
is going to serve the
www.example.com/page.html
page. If your host is so tight that mod_rewrite is disabled, I highly doubt you are going to be able to serve anything via content negotiation!