Jump to content

Escaping the "?" character


mr_mind

Recommended Posts

This is not really a PHP question as much as an Apache question but regex is the same in both applications so here goes. I have this line of code in a .htaccess file

 

# To redirect everything to the index file to be loaded
RewriteRule ^s/(.+).php$ /new/index.php?uri=$1
# I added this in to fix query strings so we dont get stuff like
# http://www.example.com/new/index.php?uri=news?show=all
# Which would not be fun
RewriteRule ^s/(.+).php\?(.+)$ /new/index.php?uri=$1&$2
# But currently the "\?" is not sufficient because in this instance it is searching
# it looks for http://www.example.com/new/s/file.php
# and http://www.example.com/new/s/file.php\
# 
# What i want to do is
# http://www.example.com/new/s/news.php?show=all
# but that does not work. Though this does
# http://www.example.com/new/s/news.php\show=all

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.