82702

.htaccess stopping URL Parameter

Question:

I'm having issues with passing a parameter over the url and I think it is related to the .htaccess file.

This page:

site.com/apprenticeships/current_vacancies

has a link to this page:

site.com/apprenticeships/current_vacancies?id=1

on the page I have:

$id = $_GET['id']; echo $id;

and in the .htaccess file there is this line of code:

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

The page with the echo in does not echo out the id. Does anyone have an idea why ?

Answer1:

When ?something is present in the second argument of RewriteRule (the part that defines what to rewrite to), then by default the query string is replaced. You want to combine both query strings, and you can do this with the QSA (query string append) flag.

RewriteRule ^apprenticeships/([^/\.]+)/?$ content.php?page=$1 [QSA,L]

Recommend

  • Parse JSON object with multiple levels Android
  • How to load a self-made TIFF image file from NSDocumentsDirectory
  • Getting Type_Gatt_Error with status 133 while connecting to AND UA651BLE
  • “NoSuchWindowException: no such window: window was already closed” while switching tabs using Seleni
  • Angular not working correctly with Meteor 1.3.1
  • Fetch Records from SQLite Database based on Query
  • Use of Expected Conditions on Non Angular Site with Protractor Leads to “Type Error: Cannot read pro
  • Extracting and Storing XML Data with libXML/XPath
  • Verify digital signature using php
  • Getting availability from datepicker for x months for a site
  • Extracting nested namespace from a xml using lxml
  • apache geode 9.0.3 Locator could not find a JMX Manager
  • ERR_SSL_SERVER_CERT_BAD_FORMAT in Chromium 6.3
  • Selenium can't find element even after explicit waiting in an Ajax Page
  • url cyrillic encoding issue (with webbrowser control)
  • ASP.NET MVC 2 - Problem with Request encoding
  • Unable to get a dynamically generated content from a webpage
  • Change in behaviour & generation of nullreference exception
  • Python - tlsv1 alert protocol version error in Docker client connection
  • file_get_Contents won't send query strings in url , thus receiving nothing with $_GET
  • Index.php as custom error page
  • How to view images from protected folder with php?
  • Webgrid not refreshing after delete MVC
  • Jquery UI tool tip close icon
  • Using $this when not in object context
  • PHP - How to update data to MySQL when click a radio button
  • How do I fake an specific browser client when using Java's Net library?
  • How reduce the height of an mschart by breaking up the y-axis
  • Perl system calls when running as another user using sudo
  • Upload files with Ajax and Jquery
  • Traverse Array and Display in markup
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Acquiring multiple attributes from .xml file in c#
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • How to stop GridView from loading again when I press back button?
  • Qt: Run a script BEFORE make
  • How can I remove ASP.NET Designer.cs files?
  • java string with new operator and a literal