root directory mod_rewrite trouble

Discuss practical ways rearrange URLs using mod_rewrite.

root directory mod_rewrite trouble

Postby mikster » Sun Apr 24, 2005 12:35 am

i have one main template -- the index.php -- and all pages are created with ?page= dynamically. since i would like to convert to a friendlier /aboutus/, which is easy to program, i've run into a problem.

I set the .htacccess as
Code: Select all
RewriteRule ^(.*)/ /index.php?page=$1


which works for what i'm going after; but now all images and scripts don't show up because they are now considered a ?page=$1 (!)
(like, /images/ and /css/)

I want the site to be "site.com/aboutus/" and not "site.com/go/aboutus" (which can be done easily and fix the root-directory-problem.)

what do you suggest?
mikster
 

Postby Caterham » Sun Apr 24, 2005 1:49 pm

what about

Code: Select all
RewriteRule ^([^/]+)/$ /index.php?page=$1 [L]
?
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby mikster » Sun Apr 24, 2005 2:28 pm

Wow, that was too simple for my own good.

Ah, adding the [L] operator ...?
Thanks, caterham
mikster
 

Postby HM » Mon Apr 25, 2005 12:15 pm

[L] means last rule. it stops processing further, although all apache seems to do if the NEW rewrritten URI is under the influence of the same .htaccess is restart the ruleset from the beginning
HM
 


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 15 guests

cron