Note that there are some explanatory texts on larger screens.

plurals
  1. POphp multi lang site clean url
    text
    copied!<p>I'm developing a multilang site. The content generated on the varible that passes in the url. Exemple for about us page my url is: domain.com/file.php?id=1 I got one main file and in that file the query gets the id of the selected menu. </p> <p>If I change the language my url turns to domain.com/file.php?id=1&amp;lang=en. Every time I change the language my url adds one more lang like this: domain.com/file.php?id=1&amp;lang=en&amp;lang=fr&amp;lang=de&amp;lang=en.....</p> <p>in other multilang project I used this: <code>header("location: ".$_SERVER['SCRIPT_NAME']);</code> But the it were less dynamic pages. like this: domains.com/aboutus.php. I mean: the number of pages were static. The user cannot add or remove pages.</p> <p>This time because I pass the page id in the url I tried <code>header("location: ".$_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING']);</code> but it gives an redirect cycle error every time I try to change the lang.</p> <p><strong>UPDATE</strong></p> <p><strong>Code to select the languages:</strong></p> <pre><code>&lt;?php $actual= $_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"];?&gt; &lt;div id="langContainer"&gt; &lt;span&gt;&lt;a &lt;?php if ($_SESSION['idLang']=='en') {echo"class='active'";}?&gt; href="&lt;?php echo $actual ?&gt;&amp;lang=en"&gt;EN&lt;/a&gt;&lt;/span&gt; &lt;span&gt;&lt;a &lt;?php if ($_SESSION['idLang']=='fr') {echo"class='active'";}?&gt; href="&lt;?php echo $actual ?&gt;&amp;lang=fr"&gt;FR&lt;/a&gt; &lt;/span&gt; &lt;span&gt;&lt;a &lt;?php if ($_SESSION['idLang']=='es') {echo"class='active'";}?&gt; href="&lt;?php echo $actual ?&gt;&amp;lang=es"&gt;ES&lt;/a&gt;&lt;/span&gt; &lt;span&gt;&lt;a &lt;?php if ($_SESSION['idLang']=='de') {echo"class='active'";}?&gt; href="&lt;?php echo $actual ?&gt;&amp;lang=de"&gt;DE&lt;/a&gt;&lt;/span&gt; &lt;/div&gt; </code></pre> <p>in my <strong>session.php</strong></p> <pre><code>if (!isset($_SESSION["idLang"]) ) $_SESSION["idLang"] = 'en'; if (@isset($_GET["lang"])){ $_SESSION["idLang"] = $_GET['lang']; //header("location: ".$_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING']); } </code></pre> <p>So my question is if there's anyway I can get my url cleaner, hidding the lang variables?</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload