CodeIgniter Forums
Query String Problem, Can't Resolve with Config Changes - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Query String Problem, Can't Resolve with Config Changes (/showthread.php?tid=32559)



Query String Problem, Can't Resolve with Config Changes - El Forum - 07-27-2010

[eluser]blzabub[/eluser]
I've got this problem described here-

http://ellislab.com/forums/viewthread/131060/

Basically, like the original poster, my email service and other places such as google ads and facebook ads are tacking on query strings before referring people to my site.

I've tried this-

Code:
$config['enable_query_strings'] = TRUE;

$config['uri_protocol'] = "PATH_INFO";

This fails for me, all my URL segments redirect to the homepage instead of to their relevant controllers/methods when the uri protocol is set to PATH_INFO. Perhaps this is because of my hosting company's configs (Site5)? I've tried the other methods: QUERY_STRING, REQUEST_URI, to no avail.

Perhaps my .htaccess file is contributing to the problem?:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

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

</IfModule>

I've tried adding a query string rewrite such as:

Code:
RewriteCond %{QUERY_STRING} .
RewriteRule (.*) http://www.mysite.com/$1? [R=301,L]

Also doesn't work.

Thanks for any help. I feel like I've read and tried solutions from 30 or 40 separate threads in the forum and none have worked.


Query String Problem, Can't Resolve with Config Changes - El Forum - 07-27-2010

[eluser]blzabub[/eluser]
I was actually able to partially solve this problem by adding the following htaccess rules-

Code:
RewriteCond %{QUERY_STRING} ^utm*
RewriteRule ^$ /main? [L]

My email service tacks on query strings that look like this-

mysite.com/?utm_source=foo&utm_campaign=bar

This solution seems to work, however, I'd prefer not to write such a rule for all possible query strings. However, it seems that if I don't have-

^utm*

Apache will redirect even my normal segment URLs like

mysite/main/contact

Thus breaking my site navigation.


Query String Problem, Can't Resolve with Config Changes - El Forum - 07-27-2010

[eluser]WanWizard[/eluser]
This has been discussed several times over the last few days.

Have you tried this: http://ellislab.com/forums/viewthread/159382/P30/#778584


Query String Problem, Can't Resolve with Config Changes - El Forum - 07-27-2010

[eluser]blzabub[/eluser]
Thanks, I actually blew past that thread earlier. I went back and re-read it.

I've come up with this solution which seems to work-

Code:
RewriteCond %{QUERY_STRING} .
RewriteRule ^$ /main? [L]

I'm able to do this without modifying uri_protocol or enable_query_strings