bear
bear

Reputation: 11625

htaccess advice - how do I write this rule?

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.

Upvotes: 0

Views: 64

Answers (2)

Nick
Nick

Reputation: 164

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

Upvotes: 1

Gumbo
Gumbo

Reputation: 655439

Try this rule:

RewriteRule ^([^/]+/)?([^/]+)\.(\d+)$ index.php?$2=$3

Upvotes: 1

Related Questions