tags:

views:

20

answers:

2

I'm not going to lie. I suck at writing htaccess rules. I'm ok with regexes though.

Ok, basically, user enters url: www.site.com/page.id or www.site.com/folder/page.id

That should be internally written to: www.site.com/index.php?page=id

I've got the stuff sorted in the index.php, but I just can't seem to hack it with the htaccess.

What do you suggest it should be?

EDIT: business/legal/service-level-agreement.10 and services.5 would need to work, so the rule would need to get the digit after the dot, period.

+1  A: 

Try this rule:

RewriteRule ^([^/]+/)?([^/]+)\.(\d+)$ index.php?$2=$3
Gumbo
Actually, it works, until I have things at the third level, e.g. business/legal/service-level-agreement.10 So what I'm basically after is something that looks for a number, which has a dot, before it. It's usually in the last bit of the string.
Shamil
@ct2k7: Just replace `([^/]+/)?` with `([^/]+/)*`.
Gumbo
Thanks Gumbo :)
Shamil
+1  A: 

The simplest way would be:

RewriteEngine On
RewriteRule ^([^/]*)$ index.php?page=$1 [L]

Take a look here maybe this can help:

generateit

cooletips

webmaster-toolkit

Nick
although the rule didn't work, thanks for the links :) The rule is doing exactly what the system is doing currently, looking at the whole lot.
Shamil