Google Adwords 和 CodeIgniter GET 变量回调 URL
我正在尝试使用使用 CodeIgniter 开发的网站来实施 Google Adwords,我相信当他们向 URL 添加 GET 变量时,它需要一个“200”状态代码。
我一直收到来自 Google 的电子邮件,称其在访问我的网址时收到 404 状态代码。当我尝试将 ?test=test 添加到 URL 末尾时,它实际上返回 404:
通过我的谷歌搜索,我发现了这个有用的链接:
http://codeigniter.com/forums/viewthread/154153/#746115
我需要更改配置以包含哪些状态:
$config['uri_protocol'] = "PATH_INFO";
$config['enable_query_strings'] = TRUE;
在我的 uri_protocol 设置为“REQUEST_URI”之前。我已经用 ?test=test 进行了测试,它确实有效!但现在我的所有链接都不起作用,当我将其切换到 PATH_INFO 时,我需要做什么来修复我的链接?
现在,我正在使用 Mod Rewrite 来缩短 URL,以便地址类似于 mydomain.com/blog、mydomain.com/about,而我的控制器仅指向适当的视图。我不应该改变我的 uri_protocol 吗?如果是的话,我怎样才能包含 GET 变量而不得到 404?
任何建议都会有帮助谢谢!
UDPATE:这是我的 htaccess 文件:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
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 Google 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]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用的是 CodeIgniter 2,您可以执行以下操作:
If you are using CodeIgniter 2, you can do:
您需要执行以下操作
1- $config['enable_query_strings'] = TRUE;
2- $config['permissed_uri_chars'] = 'az 0-9~%.:_-\?=&';
并删除“?”从您的 htaccess 文件中。
3- RewriteRule ^(.*)$ index.php/$1 [QSA,L]
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]