I'd like to know how to rewrite multiple paramaters into /param1/param2
Let's assume I have included a file called account.php with
http://myurl.com/index.php?p=account.
It works just fine and is rewritten to
but let's say I want to have multiple parameters in account.php like
http://myurl.com/index.php?p=account&settings
which should rewritten look like:
http://myurl.com/account/settings How would I do that ?
.htacces file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>
PHP Code to include the files:
$pages = array('products','about','impressum','home','support','solutions','mc','team','account');
$p = 'home';
if(isset($_GET['p'])) {
$p = $_GET['p'];
}
if(in_array($p, $pages)){
include 'includes/'.$p.'.php';
}
else {
include 'includes/home.php';
}
I work with this code in my website is does what you looking for
RewriteEngine on
RewriteBase /
RewriteRule ^post/([^/]+)/([^/]+)$ single.php?post_type=$1&post_id=$2 [QSA]