Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6123043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:58:10+00:00 2026-05-23T15:58:10+00:00

In my code, I create a link like this: $link = ‘http://www.mydomain.com/’.urlencode($str).’/1′; I use

  • 0

In my code, I create a link like this:

$link = 'http://www.mydomain.com/'.urlencode($str).'/1';

I use url-rewriting and the rule in my htaccess file looks like this:

rewriteRule ^(.+)/(.*)$ index.php?var1=$1&var2=$2 [NC,L]

This code is working fine for almost every strings. But sometimes, the string to encode contains “&”. The urlencode function encodes it corectly, but when I read the $_GET array in php, it looks like this (with $str = ‘substring1&substring2’):

'var1' => 'substring1' (without "&")
'substring2' => '' (without "&")
'var2' => 1

I really need the “&” in my var. Is there a way to encode that character to make it works?

Also, I really don’t know why, but sometimes I get a forbidden http error with some strings passed as var1. Apparently, they have nothing special, for exemple, “Décarie Square” makes that error. Other strings with spaces and “é” are working fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:58:11+00:00Added an answer on May 23, 2026 at 3:58 pm

    Apache’s mod_rewrite automatically decodes urlencoded strings when it does regex matching. But it only does this once, so you should be if you urlencode your string twice. This will re-escape all of those `%’ characters.

    try

    $link = 'http://www.mydomain.com/'.urlencode(urlencode($str)).'/1';
    

    or stop relying on rewrite rules and use a framework that handles URL routing properly.

    Oh, and there should also be htmlentities() somewhere in there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use code like this to dynamically create some link-based controls: <script type=text/javascript> function
I found the following code to create a tinyurl.com url: http://tinyurl.com/api-create.php?url=http://myurl.com This will automatically
I used this link http://blog.androgames.net/85/android-accelerometer-tutorial/ to create an accelerometer. But I want that this
I use the following code to create countdowns in Javascript. n is the number
I'm trying to create a cancel link that looks like an x with a
I have some code that creates a table like this: for($i=0; $i<$fields_num; $i++) {
I have code like this: bool doSomething() { std::cout << I'm here! return true;
I have 2 mappings like this: <hibernate-mapping> <class name=A table=A> <id name=code column=aCode type=integer>
I use jquerylive plugin to add additional css classes to .field-validation-error class like this:
trying to create a form inside a modal dialog. But i would like this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.