简体   繁体   中英

.HTACCESS: $_GET variable from URL Friendly htaccess

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM