Page 1 of 1

.htaccess Multiple Variables

Posted: Thu Oct 24, 2013 11:40 am
by tomzace
Hello everyone.
I am pulling my hair out trying to get my .htaccess file to allow a domain such as mydomain.com/something/someone

Here is my code so far:

Code: Select all

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%2://%1%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?page=$1 [QSA,L]
I have tried all sorts, but still cant get this thing working! The code I have posted removes the use of www. before my site, and allows one variable such as mydomain.com/index.php?page=XXX, I just cant get another one working, I would like mydomain.com/index.php?page=hello&section=goodbye.

Any help is much appreciated.
Tom.

Re: .htaccess Multiple Variables

Posted: Thu Oct 24, 2013 12:42 pm
by requinix
That should work by rewriting to index.php?page=something/someone. How is it not working? 404? Showing the wrong page?

Re: .htaccess Multiple Variables

Posted: Thu Oct 24, 2013 2:55 pm
by tomzace
I have managed to figure something out

Code: Select all

RewriteRule ^(.*)/(.*)$ index.php?page=$1&section=$2
This works as I want it to, but only if I remove

Code: Select all

RewriteRule ^(.*)$ index.php?page=$1 [QSA,L]
From my htaccess file. Is there a way I can get them both working simultaneously?

Re: .htaccess Multiple Variables

Posted: Thu Oct 24, 2013 3:51 pm
by tomzace
I found the solution here for anyone else who finds this problem:

http://stackoverflow.com/questions/1478 ... parameters

Re: .htaccess Multiple Variables

Posted: Tue Dec 16, 2014 6:18 am
by alexender
That should work by rewriting to index.php?page=something/someone. How is it not working? 404? Showing the wrong page?