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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Feb 2010
    Posts
    104
    Thanks
    5
    Thanked 3 Times in 3 Posts

    .htaccess url mod_rewrite query string

    All pages must redirect to a single file to be run: module.php

    When a page has an extra variable in the query string such as below the images and links are broken on the page as they require '../' as a prefix.

    Code:
    http://localhost/module/pages/editPage/&id=1/
    (the above URL passes the module and id variable successfully)

    Is there a way to pass extra query string values with a script without the URLS changing with the addition of a query string variable?



    My .htaccess file:

    Code:
    RewriteEngine on
    RewriteBase / 
    
    RewriteCond %{THE_REQUEST} ^.*\/index\.php\ HTTP/
    RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !example.php
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ $1/ [L,R=301]
    
    RewriteRule ^module/(.*)/$ module.php?module=$1 [NC]

  • #2
    New Coder
    Join Date
    Jul 2011
    Posts
    67
    Thanks
    0
    Thanked 13 Times in 13 Posts
    The URI you posted doesn't have a valid query string... But if you have a query srtring in a URI that you are rewritting and you want the query string to remain/be combined with the new ones you are adding, then you need to add the QSA flag.


  •  

    Posting Permissions

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