[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

mod_rewrite

Posted on 2011-02-12
4
Medium Priority
?
297 Views
Last Modified: 2012-05-11
Hi Guys,

Wondering if you can help shed some light on my problem,

At the moment im makng a system where i have
http://url/index.php?page=cnt_name

sometimes i  then need to pass variables to pages if i want to skip
http://url/index.php?page=cnt_name&funct=1&blah=2

i have attached my htaccess file,

is there a way that i can have it so

http://url/page

but then if i want to add variables it can be

http://url/page?variable=1&variable=2&blah=3

without having to create a rule within htaccess file for each page?

Best Regards
ben



RewriteEngine on
###################################################
# Do not process images or CSS files further      #
###################################################
# No more processing occurs if this rule is       #
# successful                                      #
###################################################

RewriteRule \.(css|jpe?g|gif|png)$ - [L]


RewriteRule ^([^/\.]+)/?$ /index.php?page=$1 [L]

Open in new window

0
Comment
Question by:Benji_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 26

Assisted Solution

by:arober11
arober11 earned 400 total points
ID: 34880554
Simple just add a QSA - "Query String Append" flag to a base rule e.g.

RewriteRule ^/?page$   /index.php?page=cnt_name  [QSA,L]
0
 
LVL 2

Author Comment

by:Benji_
ID: 34882202
Hi,

i tried the above code, now i think i might just be besing stupid

the first bit how dows that understand what  cnt_name is  becuase cnt_name changes depending on what the page variable is, and how to you apend a variable to a string?

Best regards
ben
0
 
LVL 5

Accepted Solution

by:
onemadeye earned 1600 total points
ID: 34921764
Try this:

RewriteEngine on
RewriteRule ^(.*)$   index.php?page=$1  [QSA,L] 

Open in new window


Any variables that follows should be not a problem.

Example:
* http://url/index.php?page=cnt_name&var1=text1&var2=text2
(called as) http://url/cnt_name?var1=text1&var2=text2

** http://url/index.php?page=newpage&var1=text1&var2=text2
(called as) http://url/newpage?var1=text1&var2=text2
0
 
LVL 2

Author Closing Comment

by:Benji_
ID: 35194581
Thanks Guys
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

649 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