1

I want to convert last / to ? for a url.

For eg. : /custom/2342546578 to custom?2342546578 using htaccess rule.

where custom is my page and last string is the unique id for customer identification.

How to use htaccess rule for redirection?

1 Answer 1

1

You can use the following RewriteRule in your root/.htaccess

RewriteRule ^custom/([A-Za-z0-9]+)/?$ /custom?$1 [L]

This will rewrite your url from /custom/123 to /custom?123 .

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

4 Comments

The id may be alpanumeric not numeric. And I want to redirect url not rewrite.
I have updated the pattern to accept alpha numbric charecters. Change [L] to [L,R] if you want to redirect the request instead of rewriting it .
The link showing 500 internal server error after using this rule.
Sorry there was a typo when I updated the post. I fixed it . Can you copy the code again?

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.