简体   繁体   中英

.htaccess rule does rewrite URL in address bar

I have a website where my links look like this http://www.domain.com/index.php?lang=English&inc=canyoning I managed to write rewriteRule like this:

RewriteRule (German|English)\\/(.*) http://www.domain.com/index.php?lang=$1&inc=$2 [NC,R]

Now my links look like this: <a href="http://www.domain.com/English/canyoning"> ...

This works, but I can see non user friendly URL in browser address bar. How can I tell browser to use link like /English/canyoning in URL and not index.php?lang=English&inc=canyoning ?

And second: I would like to use forms on page. There is no difference, whether I use form method =GET or POST, No variables come to destination site.

I guess there is my rewriteRule wrong. How to fix those issues?

Thank you for help!

This is because you are doing a redirect not a rewrite.. (The R flag indicates a Redirect )

So remove the R flag should fix your issue.

You may also need to remove the hardcoded domain. As you are doing a rewrite you cant rewrite to a different domain.

ie. Change

RewriteRule (German|English)\/(.*) http://www.domain.com/index.php?lang=$1&inc=$2 [NC,R]

To

RewriteRule (German|English)\/(.*) /index.php?lang=$1&inc=$2 [NC]

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