Web Niraj
  • Facebook
  • Flickr
  • Github
  • Linkedin
  • Twitter
  • YouTube
Online portfolio, code examples and developer blog
  • Home
  • About Me
  • Contact Me
  • Portfolio
  • WordPress
Search the site...
  • Home
  • Blog
  • Using .htaccess Files to hide Query Variables

Using .htaccess Files to hide Query Variables

0

I came into a recent issue where I wanted to hide ?id=xx from the query string of a URL so I could use a single Facebook Comment Plugin with different data. I fixed the issue by using a few lines of code in a .htaccess file.

RewriteBase /
RewriteRule ^file-([0-9]+)\.php$ /some_directory/files.php?id=$1 [L]

The code above simply points URLs like file-1.php to a single PHP file, but modifies the query string to make files.php?id=1. This means I can hide the query string and make the Facebook Comment Plugin think each page is unique. Since Facebook doesn’t allow query strings in the plugin, this is a elegant solution to make it work.

Apache, Tutorial

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

StackExchange / StackOverflow

profile for Niraj Shah on Stack Exchange, a network of free, community-driven Q&A sites

Tags

Amazon Web Services Android Android 4.4 KitKat Android 5.0 Lollipop Apache API Application Backup Bug Command Line Cordova Example Facebook Facebook Graph API Facebook PHP SDK 4.0 Facebook Social Plugins Fan Page Flash Geolocation Google Nexus 5 Google Nexus One Hacking HTML5 Image Manipulation iOS iPhone JavaScript jQuery Laravel 5 Linux NodeJS Parse PDF PHP Plugin Portfolio Review Security Server SSH SSL Sysadmin Tutorial WordPress WordPress Plugins
© 2011-2021 Niraj Shah
  • Privacy Policy
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkPrivacy Policy