Welcome Guest, Not a member yet? Register   Sign In
How to "fake" query strings in URLs?

It's a little bit late here, so sorry if this question has an obvious answer.

I am using mod_rewrite to get rid of the index.php in my CodeIgniter URLs and just for beautification I add an ".html" suffix on my URLs.

Relevant line in .htaccess:

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

Now let's say I have an example url like


From different pages, I would like to link to this page with a different "faked" query string for tracking user click paths. Examples:


Is what I want to achieve even possible with CI? Or do I rather have to apply some more sophisticated mod_rewrite voodoo?

Check the user guide. There's a config setting that lets you 'enable_query_strings'.

Sorry, I should probably have mentioned that. I am aware of the enable_query_string option but that is absolutely not what I want.

I want to use normal CI behavior with URL segments, I'd just like to be able to add the "fake query" (e.g. a "?ref=something") part without breaking any functionality. It will have absolutely no functionality on the server or CI side, it's just for logging and tracking purposes. (In log files, and for Google Analytics)

Ahh... I think that breaks things. If you put a slash before your query string, CI will treat it as just another URL segment. As long as you're not doing anything with that segment in your app you should be good to go. So...

if you set the uri_protocol to path_info or one of his siblings. the query string is ignored by CI and you can use it for all kinds of purposes.

will give it a try. Thanks!!

Theme © iAndrew 2016 - Forum software by © MyBB