LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-14-2006, 01:02 AM   #1
basahkuyup
LQ Newbie
 
Registered: Oct 2006
Posts: 2

Rep: Reputation: 0
Rewrite rule with query string in the pattern string


I am new to linux and php. I am facing a problem in rewriterule that needs a solution to.

I would like to do a rewrite rule for the following:
from: products/8.html?start=2&pageno=2
to: productlist.php?catid=8&start=2&pageno=2

which is the second page of products with category 8. I have tried this in my .htaccess:

RewriteRule ^products/([0-9]+).html$ productlist.php?catid=$1 [L]

but it didn't work. It still gave me the first page. The values for 'start' and 'pageno' were not passed.

I tried putting QSA (Query String attach) as the following:

RewriteRule ^products/([0-9]+).html$ productlist.php?catid=$1 [L, QSA]

still did not work. Values for 'start' and 'pageno' still not passed.

Any input is welcome.
 
Old 10-16-2006, 07:55 AM   #2
hobey
LQ Newbie
 
Registered: Feb 2006
Distribution: SuSE 10.0
Posts: 17

Rep: Reputation: 0
Works for me. (I tested it using exactly the same line in a .htaccess file and a script called productlist.php which would do nothing but output all the GET variables, and it showed all three of them with the correct values) The only thing is that there must be no space behind the comma in [L,QSA] (gave me a server error otherwise).

You might try to do the same. Just temporarily replace your productlist.php by something like 'print_r($_GET);' and see what variables it receives (add some <pre> tags to make output legible in the browser).
 
Old 10-17-2006, 02:06 AM   #3
basahkuyup
LQ Newbie
 
Registered: Oct 2006
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by hobey
Works for me. (I tested it using exactly the same line in a .htaccess file and a script called productlist.php which would do nothing but output all the GET variables, and it showed all three of them with the correct values) The only thing is that there must be no space behind the comma in [L,QSA] (gave me a server error otherwise).
Thanks hobey.

I removed the space and it works. Man, what a difference can a space makes.
Thanks again.
 
  


Reply

Tags
htaccess


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash search for a pattern within a string variable nutthick Programming 7 03-06-2012 03:54 AM
How to replace string pattern with multi-line text in bash script? brumela Linux - Newbie 6 04-21-2011 06:56 AM
java, search character pattern in string howto xemous Programming 2 08-09-2006 07:53 AM
mysql query for multibyte string onnyloh Programming 3 12-03-2004 08:29 PM
Find string pattern in directory of text files magnum818 Linux - Newbie 2 10-15-2003 08:19 PM


All times are GMT -5. The time now is 03:24 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration