Welcome Guest, Not a member yet? Register   Sign In
How To use Query Strings with CodeIgnter (and still have Pretty URLs)
#1

[eluser]NTICompass[/eluser]
I have query strings enabled, and I still use pretty URLs in CodeIgniter.

Using .htaccess, I can rewrite the URLs correctly and also pass query strings to the controllers.

The following code is used for my RPX Login library (http://codeigniter.com/wiki/RPX_Login/).

Code:
RewriteEngine On
Options +FollowSymlinks
Options -Indexes
RewriteBase /

RewriteRule ^rpxlogin$ index.php?c=rpx [QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

Basically http://example.com/rpxlogin calls the controller named rpx. When http://example.com/rpxlogin?test=123 is called it is rewritten as http://example.com/index.php?c=rpx&test=123

Hope this helps people.




Theme © iAndrew 2016 - Forum software by © MyBB