Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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?

share|improve this answer

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]
share|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 '12 at 13:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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