NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page htaccess rewrite and GET variables

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
7 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 05-11-2010, 10:55 AM THREAD STARTER               #1 (permalink)
NamePros Regular
 
asgsoft's Avatar
Join Date: Sep 2005
Location: At Home
Posts: 881
asgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of light
 



htaccess rewrite and GET variables


I am trying to get variables from URLs, rewritten by htaccess and which are passed on using GET.

At the moment I have:

PHP Code:
Options +FollowSymLinks
RewriteEngine On

RewriteRule 
^eating-out.php?sort=(.+)&page=(.*)$ dev1.php?cat=1&sort=$1&page=$
Which is getting me a 404 error page when I access eating-out.php.. meaning the page isn't found.

However, if I use this:

PHP Code:
Options +FollowSymLinks
????: NamePros.com http://www.namepros.com/code/655815-htaccess-rewrite-and-get-variables.html
RewriteEngine On

RewriteRule 
^eating-out.php dev1.php?cat=
And try and access eating-out.php?page=2 it won't work.. the value of $_GET['page'] is still nothing.

Any ideas?
asgsoft is offline  
Old 05-11-2010, 11:38 AM   #2 (permalink)
NamePros Regular
 
chadsmith's Avatar
Join Date: Jul 2008
Location: Wichita, KS
Posts: 287
chadsmith is just really nicechadsmith is just really nicechadsmith is just really nicechadsmith is just really nice
 




The first one isn't working because sort and page are part of the query strings.

You should only need to add [QSA] to append the query string to the second rewrite:
????: NamePros.com http://www.namepros.com/showthread.php?t=655815

Code:
RewriteRule ^eating-out.php dev1.php?cat=1 [QSA]
or better yet

Code:
RewriteRule ^eating\-out\.php$ /dev1.php?cat=1 [L,QSA]
chadsmith is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 07:34 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger