overly complicated rulesets breaking stuff

Discuss practical ways rearrange URLs using mod_rewrite.

overly complicated rulesets breaking stuff

Postby mikhail » Tue May 11, 2004 7:42 pm

The idea was to create a set of rules that used clean URLs for sets of files all served from the root directory. Also wanted to add the trailing slash for any URLs that were missing it.

So if I have a URL like http://www.mydomain.com/foo-bar/ it points to a file called fb_index.php (in this case).

And if I have a URL like http://www.mydomain.com/foo-bar/myfile/ it points to fb_myfile.php

I also have URLs such as http://www.mydomain.com/fubar/ which simply point to fubar.php

There will also be actual subdirectories, but the main problem right now is the rulesets I've come up with screw with other internal directories, as well as the root.

Can this be cleaned up, or am I making things too complicated?

Following is the rulesets I've come up with:


Code: Select all
RewriteCond   %{REQUEST_FILENAME}   -d
RewriteRule   ^(.+[^/])$   $1/   [R]

RewriteCond   %{REQUEST_URI}   ^/((.)[a-zA-Z]*)-((.)[a-zA-Z]*)/([0-9a-zA-Z]*)/
RewriteRule   ^(.*)   /%2%4_%5.php   [L]

RewriteRule   ^([a-zA-Z]*)-([a-zA-Z]*)$   $1-$2/   [R]
RewriteCond   %{REQUEST_URI}   ^/((.)[a-zA-Z]*)-((.)[a-zA-Z]*)/
RewriteRule   ^(.*)   /%2%4_index.php   [L]

RewriteCond   %{REQUEST_URI}   !^/(images|css|js|cgi-bin)/      

RewriteCond   %{REQUEST_URI}   ^/([0-9a-zA-Z]*)/      
RewriteRule   ^(.*)   /%1.php   [L]
mikhail
 

Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 25 guests

cron