Google Adwords and CodeIgniter GET Variable Callback URL
I am trying to implement Google Adwords with a website that has been developed using CodeIgniter, I believe it requires a "200" status code when they add a GET variable to the URL.
I've been getting emails from Googl开发者_如何学编程e saying that it's receiving a 404 status code when it goes to my URL. When I try to add ?test=test to the end of my URL it does in fact return a 404:
Through my google searches, I have found this useful link:
http://codeigniter.com/forums/viewthread/154153/#746115
Which states I need to change my config to include these:
$config['uri_protocol'] = "PATH_INFO";
$config['enable_query_strings'] = TRUE;
Before my uri_protocol was set to "REQUEST_URI". I have tested with ?test=test and it does work! But now all my links are not working, when I switch it to PATH_INFO, what do I need to do to fix my links?
Right now I am using Mod Rewrite to shorten the URLs so that the addresses are like mydomain.com/blog, mydomain.com/about, and my controller just points to the appropriate view. Should I not change my uri_protocol, if so how can I include a GET variable and NOT get a 404?
Any advice would help thank you!
UDPATE: Here's my htaccess file:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
If you are using CodeIgniter 2, you can do:
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = FALSE;
You need to do the following 1- $config['enable_query_strings'] = TRUE;
2- $config['permitted_uri_chars'] = 'a-z 0-9~%.:_-\?=&';
AND remove the "?" from your htaccess file.
3- RewriteRule ^(.*)$ index.php/$1 [QSA,L]
精彩评论