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

[eluser]krif[/eluser]
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

http://www.example.com/samplepage.html

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

http://www.example.com/samplepage.html?ref=home
http://www.example.com/samplepage.html?r...eotherpage

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

[eluser]slowgary[/eluser]
Check the user guide. There's a config setting that lets you 'enable_query_strings'.
#3

[eluser]krif[/eluser]
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)
#4

[eluser]slowgary[/eluser]
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...
Code:
http://www.domain.com/controller/method/input/?ref=michealjackson
#5

[eluser]xwero[/eluser]
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.
#6

[eluser]krif[/eluser]
will give it a try. Thanks!!




Theme © iAndrew 2016 - Forum software by © MyBB