Carsen
Carsen

Reputation: 419

mod_rewrite condition - match "someword/" but not "someword/anotherword/"

I'm trying to rewrite a URL such as

http://www.example.com/someword/

to

http://www.example.com/someword/index/

But leave

http://www.example.com/someword/anotherword/

untouched.

I'm fairly certain this shoudl be fairly easy to accomplish but I'm not so savy with Regular Expressions and the last couple of hours I've spent digging through googled regex guides has left me with no solution thus far.

[-a-zA-Z0-9_]*/.+

suffices for giving me the opposite of what I want (matching "someword/anotherword/" but not just "someword/"). I need the opposite, to match just "someword/" but not "someword/anotherword/"

Upvotes: 0

Views: 68

Answers (1)

jagm
jagm

Reputation: 576

try this:

[-a-zA-Z0-9_]*/$

simple and fast tutorial:

.+ means any chracter one or more times
.* any character 0 or more times
$ is end of line

Upvotes: 1

Related Questions