Note that there are some explanatory texts on larger screens.

plurals
  1. POhtaccess mod rewrite $_GET to variables with slashes
    text
    copied!<p>I would like to rewrite URL's with htaccess to better readable URL's and use the $_GET variable in PHP<br> I sometimes make use of a subdomain so it has to work with and without. Also are the variables not necessary in the url. I take a maximum of 3 variables in the URL </p> <p>the URL <code>sub.mydomain.com/page/a/1/b/2/c/3</code> should lead to <code>sub.mydomain.com/page.php?a=1&amp;b=2&amp;c=3</code> and the url <code>sub.mydomain.com/a/1/b/2/c/3</code> should lead to <code>sub.mydomain.com/index.php?a=1&amp;b=2&amp;c=3</code> where <code>$_GET['a'] = 1</code> </p> <p>I came up with this after searching and trying a lot</p> <pre><code>RewriteEngine on RewriteRule ([^/]+)\.domain.com/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ $1.domain.com/$2.php?$3=$4&amp;$5=$6&amp;$7=$8 [QSA,NC] RewriteRule ([^/]+)\.domain.com/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ $1.domain.com/index.php?$2=$3&amp;$4=$5&amp;$6=$7 [QSA,NC] RewriteRule ([^/]+)\.domain.com/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ $1.domain.com/$2.php?$3=$4&amp;$5=$6 [QSA,NC] RewriteRule ([^/]+)\.domain.com/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ $1.domain.com/index.php?$2=$3&amp;$4=$5 [QSA,NC] RewriteRule ([^/]+)\.domain.com/([^/]+)/([^/]+)/([^/]+)$ $1.domain.com/$2.php?$3=$4 [QSA,NC] RewriteRule ([^/]+)\.domain.com/([^/]+)/([^/]+)$ $1.domain.com/index.php?$2=$3 [QSA,NC] RewriteRule ([^/]+)\.domain.com/([^/]+)$ $1.domain.com/$2.php [L,QSA,NC] </code></pre> <p>but what I get is an not found server error</p> <p>I'm not that good at this so maybe I oversee something.<br> Also I would like it to work with and without a slash at the end</p> <p>Should I make use of RewriteCond and/or set some options?</p> <p>Thanks in advance.</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