.htaccess Multiple Variables

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
tomzace
Forum Newbie
Posts: 3
Joined: Thu Oct 24, 2013 11:31 am

.htaccess Multiple Variables

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: .htaccess Multiple Variables

Post by requinix »

That should work by rewriting to index.php?page=something/someone. How is it not working? 404? Showing the wrong page?
tomzace
Forum Newbie
Posts: 3
Joined: Thu Oct 24, 2013 11:31 am

Re: .htaccess Multiple Variables

Post 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?
tomzace
Forum Newbie
Posts: 3
Joined: Thu Oct 24, 2013 11:31 am

Re: .htaccess Multiple Variables

Post by tomzace »

I found the solution here for anyone else who finds this problem:

http://stackoverflow.com/questions/1478 ... parameters
alexender
Forum Newbie
Posts: 1
Joined: Tue Dec 16, 2014 6:16 am

Re: .htaccess Multiple Variables

Post by alexender »

That should work by rewriting to index.php?page=something/someone. How is it not working? 404? Showing the wrong page?
kaleem
Post Reply