-1

i wrote

rewrite ^/([\w_]+)/?$ /index.php?$1

btw, i wanna except /empty.

hmm..

wanna use

/alphabet -> alphabet
/emptyABC -> emptyABC

/empty -> not match

/emp -> emp

/emptAB -> emptAB

How can I make regular expressions for these?

Tom O'Connor
  • 27,440
  • 10
  • 72
  • 148
user160153
  • 17
  • 1
  • 3

1 Answers1

0

Not sure if i understood correctly what you want, but i think you need something like this:

rewrite ^/(.+)$ $1;

The + will require at least 1 character to be behind the /. Then it takes whats behind the leading / and redirects to it.

Your examples could also imply that you want to only capture alphanumeric characters, which would be like this:

rewrite ^/([a-zA-Z0-9]+)$ $1;

replay
  • 3,180
  • 13
  • 16