Solved

mod rewrite rule variable placement after ?

Posted on 2013-01-17
2
332 Views
Last Modified: 2013-01-18
I need to know how to write a mod rewrite rule for this example.

This is the original url.
/store.php?sale=first_variable_here&page=second_variable_here

Open in new window


This will be what the new url looks like.
/store/sale/first_variable_here.htm?page=second_variable_here

Open in new window


I tried but it did not work.  
RewriteRule store/sale/(.*)\.htm?page=(.*)\$ store.php?sale=$1&page=$2

Open in new window



Thanks
0
Comment
Question by:Luey
2 Comments
 
LVL 16

Accepted Solution

by:
grahamnonweiler earned 500 total points
ID: 38792600
As the "query string" from the calling url is unaltered, simply append it to your rewrite using QSA directive (query string append).
RewriteRule ^/?store/sale/(.*)\.htm$  /store.php?sale=$1  [QSA,NC,L]

Open in new window

In the above example

www.yourdomain.com/store/sale/first_variable_here.htm?page=second_variable_here 

will rewrite to:

./store.php?sale=first_variable_here&page=second_variable_here
0
 

Author Closing Comment

by:Luey
ID: 38794121
Thanks a ton.  I did some more research on all the things you added to my code and I understand a lot more now. Worked perfect.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question