Forum Moderators: phranque

Message Too Old, No Replies

Mod Rewrite, just like wordpress does

I need to implement a rewrite condition, just like wordpress does

         

asantos

7:35 pm on Mar 11, 2006 (gmt 0)

10+ Year Member



Hi. I am developing a personalized cms for my fathers business, and ive been reading a lot about SEO, so, as you must be guessing, i need to implement the so called "permalinks" to the site.

for example, the website has 9 sections (some of them might be subsections of the other).

**This is a tree example**
www.mysite.com/about_us (db section_id = 1)
www.mysite.com/about_us/workteam/ (db section_id = 4)
www.mysite.com/about_us/employees/ (db section_id = 5)
www.mysite.com/products (db section_id = 2)
www.mysite.com/products/ice/ (db section_id = 6)
www.mysite.com/products/icecubes/ (db section_id = 7)
www.mysite.com/contact (db section_id = 3)
www.mysite.com/contact/phone/ (db section_id = 8)
www.mysite.com/contact/email/ (db section_id = 9)

What i need to do, is this:
www.mysite.com/about_us/employees/ ---> www.mysite.com/index.php?id_section=5

How can i achieve that?

I was reading another similar topic (http://www.webmasterworld.com/forum92/2907.htm) but that doesn't exactly work for my needs.

asantos

10:51 pm on Mar 11, 2006 (gmt 0)

10+ Year Member



BTW, all i've tried at the moment is this:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^([^/]+)/?$ /index.php?id_section=$1 [L]

... but of course that only works with one level. so, right know i need to find out how to:

1) how to get the number of directory identifiers --([^/]+)--

2) check consistency of identifiers. so that www.mysite.com/about_us/ice returns a 404 err

asantos

6:15 pm on Mar 12, 2006 (gmt 0)

10+ Year Member



Well... nobody replied to this, but i found this link which explains it all:

keeping-track-of-uris article at turnipspatch.com

[edited by: jdMorgan at 6:47 pm (utc) on Mar. 12, 2006]
[edit reason] De-linked. Please see Terms of Service. [/edit]