Htaccess - multiple variables

I tryed google how to do this but I cant find any that works.

I want for example:

  • main.php?module=profile to be /profile - this works
  • main.php?module=profile&show=contact to be /profile/contact - this works
  • main.php?module=profile&task=contact to be /profile/contact/task ?- I dont know how to do this? Any ideas?

Here is my htaccess

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteBase /core/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([^/]*)$ main.php?module=$1 [NC,L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ main.php?module=$1&show=$2 [NC,L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ main.php?module=$1&task=$2 [NC,L]

You are going about this the wrong way. Your site should have a single point of access, index.php, then parse the pretty url you actual want (/profile/contact) and route to the file you want.

Check out my simple example here. This is just one of many ways to do what you want.

Sponsor our Newsletter | Privacy Policy | Terms of Service