I have a htaccess-file that removes index.php (codeigniter). I am having a problem with Paypal, cause the return url is using query strings, which are troublesome in codeigniter.

This is my htaccess-file:

RewriteEngine on
RewriteBase /

# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]

I want to rewrite the following example url-s:

http://.../site/bookingconfirmed/?token=EC-56G61173NH540131H

to

http://.../site/bookingconfirmed/EC-56G61173NH540131H

and

http://.../site/bookingdeclined/?token=EC-56G61173NH540131H

to

http//.../site/bookingdeclined/EC-56G61173NH540131H

Any good ideas how to do this?

link|improve this question
feedback

2 Answers

up vote 1 down vote accepted

Something like this:

RewriteCond %{QUERY_STRING} token=([^&]+) [NC]
RewriteRule ^(site/booking.*)/?$ $1/%1? [L]

This'll make sure the trailing slash is in place too, so a request to /site/bookingconfirmed?token=EC-56G61173NH540131H will work as well. And it throws away the query string - I'm assuming there's nothing else in there you need to keep?

link|improve this answer
feedback

Something like this.. very un-tested

RewriteEngine on
RewriteBase /

# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]

RewriteRule ^site/(bookingconfirmed|bookingdeclined)/\?token\=(.*)$ /site/$1/$2 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
link|improve this answer
You probably don't need the [R=301,L] bit - after the request URI is processed by your new rule, the rewritten version should just hit the last rule and be ... er, re-rewritten to go to index.php. – meulop Jan 31 at 13:57
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.