1

In a website I found, they use friendly URLs like this:

Real URL:

example.com/index.php?mode=product

FRIENDLY URL

example.com/view/product.html

In the friendly URL, there is a feature to get a variable with $_GET function. So if the URL looks like this:

FRIENDLY URL 2

example.com/view/product.html?id=10&lang=en&cur=1

This is similar to the friendly URL but allows me to easily access variable parameters.

Can someone help me write an .htaccess rewrite rule like this?

0

1 Answer 1

1

The [QSA] directive in mod_rewrite is your friend here. It will append all the other query string parameters onto the end of the rewritten url:

Options +FollowSymlinks
RewriteEngine On
RewriteRule ^view/(.*).html /index.php?mode=$1 [QSA]

That is untested, but just a quick answer that should get you going.

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

1 Comment

The (.*) might be a little too greedy, but that's the basic idea.

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.