繁体   English   中英

重定向的Codeigniter URL或多余的部分已添加到URL

[英]Codeigniter URLs being redirected or extra part is added to URL

我有一个奇怪的问题。 直到昨天一切都很好,突然发现了这个问题。

网站在这里: http : //www.famtripsandinspectionvisits.com/all_trips

如果您访问上面的页面并单击“印度喀拉拉邦”链接,它将带您进入下一页。

http://www.famtripsandinspectionvisits.com/trips/old_trips/india_kerala

但是,浏览器将重定向到此页面: http : //www.famtripsandinspectionvisits.com/all_trips/old_trips/india_kerala?/ trips/old_trips/ india_kerala这表明添加了以下内容,这是多余的。 all_trips / old_trips / india_kerala?

我检查了.htaac​​cess并将其重置为默认值,但它仍然不影响它。 我检查了cofnig.php的基本URL,所有内容与以前相同。 如果有人可以帮助,我会提出申请。

我的.htaccess文件

# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]  

Redirect 301 /invest.php http://www.famtripsandinspectionvisits.com/investment_opportunity
Redirect 301 /buyers.php http://www.famtripsandinspectionvisits.com/buyers
Redirect 301 /trips.php http://www.famtripsandinspectionvisits.com/all_trips
Redirect 301 /sellers.php http://www.famtripsandinspectionvisits.com/sellers
Redirect 301 /contact.php http://www.famtripsandinspectionvisits.com/contact_us
Redirect 301 /about.php http://www.famtripsandinspectionvisits.com/about_us
Redirect 301 /login.php http://www.famtripsandinspectionvisits.com/login
Redirect 301 /trip-kerala.php http://www.famtripsandinspectionvisits.com/trips/old_trips/india_kerala
Redirect 301 /trip-burundi.php http://www.famtripsandinspectionvisits.com/trips/up_coming_trips/burundi_africa
Redirect 301 /register.php http://www.famtripsandinspectionvisits.com/register
Redirect 301 /trips http://www.famtripsandinspectionvisits.com/all_trips

我的routes.php

$route['default_controller'] = "site";
$route['404_override'] = '';

$route['fam_admin'] = "fam_admin/login";
/* End of file routes.php */
/* Location: ./application/config/routes.php */

亲切的问候

我认为您在这里需要做的就是告诉mod_rewrite您想组合新旧查询字符串,这需要使用QSA标志:

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

这是我的Codeigniter项目的“标准”基本规则集,其余的我将通过自定义路由和偶尔的重定向来完成您所能完成的工作。

仅用问号(在没有QSA标志的情况下)结束替换将删除现有查询字符串,并将其替换为新的查询字符串,我认为这可以解释您所看到的内容。

关于mod_rewrite文档在此方面有更深入的介绍:

修改查询字符串

默认情况下,查询字符串不变。 但是,您可以在包含查询字符串部分的替换字符串中创建URL。 只需在替换字符串中使用问号来表示应将以下文本重新插入到查询字符串中。 当您要删除现有的查询字符串时,只需用问号结束替换字符串。 要组合新旧查询字符串,请使用[QSA]标志。

我有类似的问题。 尝试编辑config.php使其看起来像这样:

$config['index_page'] = 'index.php?';

我假设您正在使用CodeIgniter的URL方法之一,并且(假设)正在使用IIS进行托管。 我不知道如何删除“?” URL和查询字符串之间,但添加“?” 到您的配置文件应至少解析链接。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM