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

4
  • Hi, and welcome to StackOverflow! please format your code correctly. Thanks! To learn how to do so , click on the orange question mark i.i.imgur.com/BApIf.png Commented May 12, 2011 at 19:14
  • What version of CI are you using? Have a look in the config file for the url parameter settings. Commented May 12, 2011 at 20:17
  • the url without the query string (what follows the ?) works ? Commented May 12, 2011 at 20:49
  • What happens if you change the config file to accept query stings? It's off by default. Commented May 12, 2011 at 20:53

6 Answers 6

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
Sign up to request clarification or add additional context in comments.

1 Comment

you must use your own directories :)
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.

Comments

1

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

Comments

0

Related:

CodeIgniter PHP Framework - Need to get query string

Enabling $_GET in codeigniter

Comments

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,

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.