php - mod_rewrite changing /subpage/ to /subpage -
okey, problem. want use mod_rewrite make nice looking urls site.
i want them have looking url www.mypage/tennis or www.mypage/soccer instead of www.mypage/?page=tennis , www.mypage/?page=soccer
and following rules can achive this:
options +followsymlinks rewriteengine on rewritecond %{script_filename} !-d rewritecond %{script_filename} !-f rewriterule .* index.php [l]
so if type in www.mypage/soccer php script reads url , it's magic translating $_get['page'] = soccer. works fine!
problem is if type url www.mypage/soccer/ of sudden every linked css or image cannot found website, since looking in none existing folder /soccer/ off course.
how make rewrite rule transforms /soccer/ /soccer or other /blabla/ /blabla
hope question clear! if have pages can learn more regular expressions happy!
try this:
rewriterule ^([a-za-z0-9-]+)/?$ ?page=$1 [l]
Comments
Post a Comment