2

I want to rewrite the url using .htaccess

Here is my main url which will be accessed by public:
http://example.com/watch?v=123456789

I want same values of get parameters but in new location:
http://example.com/index.php?v=123456789

How can i do this? Help will be appreciated! Thanks.

1 Answer 1

3

it could be something like.. (.htaccess at root level)

RewriteRule ^watch/?$ index.php [QSA,L]

The important thing is the QSA option ("QueryString Append")

Hope it helps!

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

2 Comments

@starkeen, I don't think that your correction is.. correct. Because the slash isn't provided in the original example (despite of the optional question mark).. At the most, it could be something like RewriteRule ^watch(.php)?$ index.php [QSA,L]. Adding the slash would mean that watch could be a directory
The slash is optional there so that the rule can accept both /watch and /watch/ . Also if the watch is an existent dir then the rule won't match the pattern unless you spacify a traling slash to the directory path.

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.