1

I want to match shop name from a url .Please see the example below. Its for url redirection in a word press application.

See the examples given below

http://example.com/outlets/19-awok?page=2
http://example.com/outlets/19-awok
http://example.com/outlets/159-awok?page=3

In all cases i need to get only awok from the url .It will be the text coming after '-' and before query string .

I tried below and its not working

/outlets/(\d+)-(.*)? => /shop/$2

Any help will be greatly appreciated.

4
  • Use: /outlets/\d+-([^?]+) Commented Apr 5, 2017 at 18:55
  • Thanks . But its giving 'shop/awok/?page=12' . Its not removing the querystring part :( Commented Apr 5, 2017 at 19:00
  • That is because of your plugin. Try this in target URI: /outlets/\d+-([^?]+)? (with a trailing ?) Commented Apr 5, 2017 at 19:03
  • thank you please post it as answer . i will make it as accepted answer Commented Apr 5, 2017 at 19:06

1 Answer 1

1

You can use this regex:

/outlets/\d+-([^?]+)?

Trailing ? is used to strip previous query string.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.