0

I have a problem with Url Rewrite in my multilingual site, or better, maybe I don't understand it very well.

My original link is something like

www.mydomain.com/index.php?lang=en&s=2

I write this rule:

RewriteEngine On RewriteRule ^([^/]*)/([^/]*)\.html$ index.php?lang=$1&s=$2 [L]

and it's work. In fact if I write in the address bar

www.mydomain.com/en/2.html (smart url)

I go to the correct page with a smarter url on the address bar.

But the problem is that the link on my code is still:

<a href="index.php?lang=<?php echo $lang?>&s=2">link</a>

and when I click it, the URL on the address bar is the original, not the smart one.

I thought that the rule on htaccess would have automatically "turned" (in the address bar) all my links in something smarter without changing the original php code...but maybe I'm wrong. If I'm wrong how should I write my links in order to have smart urls but passing variables to identify languages and pages? I'm confused.

Thank you.

DevTen
  • 15
  • 5
  • Possible duplicate of [.htaccess how to force/automatic clean URL](http://stackoverflow.com/questions/14564258/htaccess-how-to-force-automatic-clean-url) – node_modules Apr 26 '17 at 13:04
  • You are rewriting certai .html pages to point to .php pages. Your `a` tag links to a .php page. What's the problem? – Pyromonk Apr 26 '17 at 13:06

1 Answers1

0

After rewriting URL in your .htaccess you need also to change the URL in your page for example in given link <a href="index.php?lang=<?php echo $lang?>&s=2">link</a> you need to remove question mark <a href="index.php/<?php echo $lang?>/2">

Carl Angelo Nievarez
  • 573
  • 1
  • 11
  • 33
  • How can I modify my rule if I would have another parameter in the url, like a title? Something like **www.mydomain.com/index.php?lang=en&s=2&title=title-example** to obtain **www.mydomain.com/en/title-example.html** (the title instead of the id). Thank you. – DevTen May 02 '17 at 08:25