2

I used an htaccess in my project that use Codeigniter framework:

DirectoryIndex index.php

RewriteEngine on

RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico) [NC]

RewriteCond %{REQUEST_FILENAME} !-f [NC]

RewriteCond %{REQUEST_FILENAME} !-d [NC]

RewriteRule ^(.*)$ ./index.php/$1 [NC,L,QSA]

My problem is, when i call a paypal service, Paypal response for me an GET url, like that: http://xxx.xx.com/myproject/paypalCallback?tx=32J30607S6157364F&st=Pending&amt=85.00&cc=SGD&cm=&item_number=

I receive a 404 page not found. Htaccess doesn't accept GET URL: ?tx=32J30607S6... I sure it's work on local, but not on live side

If you can, please help me. Thanks

Trufa
  • 39,971
  • 43
  • 126
  • 190
Tuan
  • 61
  • 2
  • 10

6 Answers6

1

One thing that may work that you can try is putting a plain php file in your base directory called paypalcallback.php or something along those lines with the following code:

$tx  = $_GET['tx'];
$st  = $_GET['st'];
$amt = $_GET['amt'];
... etc ...

header("location:/myproject/papalCallback/$tx/$st/$amt");
exit;

It basically reads query strings and converts to url segments. Generally it's easier than messing with the query strings and creating fancy rewrite rules. I use it for linking to a image manager in CKeditor, because it requires a querystring variable in the callback.

I guess most of this would depend on whether or not the http header code matters.

Josh
  • 932
  • 7
  • 12
1

You need to enable query string in application/config/config.php or enabled '?' character in $config['permitted_uri_chars']

a77icu5
  • 131
  • 2
  • 13
1

yes this works in CI

you can still access query string if they are disable in CI, try this code

To remove index.php from URL

RewriteEngine On

RewriteCond %{REQUEST_URI} ^system.*

RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L]

if you have CI app in sub directories use this

RewriteBase /f2f/f2fweb
gen_Eric
  • 223,194
  • 41
  • 299
  • 337
Waqar Alamgir
  • 9,828
  • 4
  • 30
  • 36
0

Related:

CodeIgniter PHP Framework - Need to get query string

Enabling $_GET in codeigniter

Community
  • 1
  • 1
leonbloy
  • 73,180
  • 20
  • 142
  • 190
0

First, thanks all of you, my friends,

I try to follow all your posts. And finaly, I found the correct way for my case, it's very simple. I change htacces file like this:

RewriteRule ^(.*)$ ./index.php?/$1 [NC,L,QSA]

You see, i insert '?' before '/'. It's will accept my URL ..paypalCallback/?tx=123213.

It's work. May be I'm lucky ^ ^

Anyway, thanks for your help

Cheers,

Tuan
  • 61
  • 2
  • 10
0

The following steps worked for me after googling for few hours :

  1. In application/config/config.php i used this change

      $config['enable_query_strings'] = TRUE;
      $config['index_page'] = "";
    
  2. In .htaccess

     RewriteEngine on
     RewriteCond $1 !^(index\.php|application|media|images|robots\.txt)
     RewriteRule ^(.*)$ /index.php?/$1 [L]
    
  3. In /system/libraries/URI.php

     Replace
    
        if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", $str))
    
     With
    
        if ( ! preg_match("|^[".str_replace('\\-', '-', preg_quote ($this->config->item('permitted_uri_chars')))."]+$|i", $str))
    

That's it. I took one of these solution from http://dragffy.com/blog/posts/codeigniter-17-the-uri-you-submitted-has-disallowed-characters