Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder LearningCoder's Avatar
    Join Date
    Jan 2011
    Location
    The Pleiades
    Posts
    923
    Thanks
    76
    Thanked 29 Times in 29 Posts

    dealing with 2 $_GET variables with mod_rewrite

    Good afternoon all,

    I am having a problem with passing 2 values through my URL and I think it's something to do with my .htaccess file.

    When any internal link on my site is clicked, I pass a $_GET variable and depending on that value, display the relative page.

    I have an 'Offers' page containing 3 offers. There is a link for each offer and the idea is to populate my textarea on my contact page with the value of the offer, should they be linked to my contact page via the Offers page.

    Trouble is, my .htaccess file I believe only deals with the instance of 1 $_GET value being passed, but anymore and it doesn't work.

    My is here:

    Code:
    RewriteEngine on
    RewriteBase /
    RewriteRule ^/?([a-zA-Z_]+)$ index.php?page=$1 [L]
    How can I accommodate multiple values being passed?

    The website link is here: http://www.tspv-websites.co.uk/Offer

    Kind regards,

    LC

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,856
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    If you use something like
    Code:
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]
    you may get everything redirected to index.php page.

    From there, if you explode $_SERVER['REQUEST_URI'] based on /, you may get the required parameters. Additionally, the QSA option enables you to get $_GET array, for urls like /Offer/?item=1
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder LearningCoder's Avatar
    Join Date
    Jan 2011
    Location
    The Pleiades
    Posts
    923
    Thanks
    76
    Thanked 29 Times in 29 Posts
    Hi abduraooft,

    Would I add that to what I currently have or replace what I have but keeping the first 2 lines?

    Kind regards,

    LC

  • #4
    Regular Coder LearningCoder's Avatar
    Join Date
    Jan 2011
    Location
    The Pleiades
    Posts
    923
    Thanks
    76
    Thanked 29 Times in 29 Posts
    Good evening,

    Update:

    I've nearly got it working and the page loads, but for some reason the stylesheet is not being applied. Although when I look through developer tools, it is loaded in the <head>. No elements have any style whatsoever.

    If you visit here: http://www.tspv-websites.co.uk/Offer and click on the Deal 1 button, you will see exactly what I mean.

    Here is my code:
    Code:
    RewriteEngine on
    RewriteBase /
    RewriteRule ^/?([a-zA-Z_]+)$ index.php?page=$1 [L,QSA]
    RewriteRule ^/?([a-zA-Z_]+)/([a-zA-Z_0-9]+)$ index.php?page=$1&deal=$2 [L]
    The URL looks good, the stylesheet is showing as loaded. This is very strange.

    Anyone got any thoughts?

    Kind regards,

    LC.

  • #5
    Regular Coder LearningCoder's Avatar
    Join Date
    Jan 2011
    Location
    The Pleiades
    Posts
    923
    Thanks
    76
    Thanked 29 Times in 29 Posts
    I'm getting this error in the console:


    Thanks again

    Kind regards,

    LC.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •