2

I have the url such as example.com/page.php?username=test. I want to rewrite this url into something like: example.com/test only if test follows the following regual expression: /^[0-9a-zA-Z_-]{1,35}+$/, else 404 page.

1 Answer 1

4

Try this:

# output: example.com/test rewrite ^/([A-Za-z0-9_]+)$ /page.php?username=$1; 

UPDATE:

{1,35} This expression allow from 1 to 35 character

{20} That have to exactly 20 character

The + say minimum 1 character

The correct full rewrite rule:

# output: example.com/test rewrite "^/([A-Za-z0-9_]{1,35})$" /page.php?username=$1; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.