首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在.htacces &Itemid=x中重定向到&Itemid=Y

如何在.htacces &Itemid=x中重定向到&Itemid=Y
EN

Stack Overflow用户
提问于 2012-09-08 06:27:09
回答 1查看 622关注 0票数 0

你好,我有这个问题

我无法将此index.php?option=com_adsmanager&view=list&catid=8&Itemid=435重定向到此index.php?option=com_adsmanager&view=list&catid=8&Itemid=565

catid=8是一个变量,我需要重定向所有的catid=值

即时通信Im只需要将&Itemid=435转换到&Itemid=565

我有这个代码

代码语言:javascript
复制
   RewriteEngine on
    RedirectMatch 301 ^(.+)\&Itemid=435$ $1&Itemid=565

我不知道出了什么问题,我需要所有的urls anything&Itemid=435去sameanything&Itemid=565

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-08 07:22:59

替代

index.php或Joomla的configuration.php的顶部添加下面的PHP Code

它检查数字catid & Itemid请求&如果是Itemid=435,它将用catid和新的Itemid重定向URL。请根据您的需要随意修改代码!

代码语言:javascript
复制
if(isset($_GET['catid']) && is_numeric($_GET['catid']) && isset($_GET['Itemid']) && is_numeric($_GET['Itemid']))        
if($_GET['Itemid'] == 435)
{
    $catid    = $_GET['catid'];
    $location = "/index.php?option=com_adsmanager&view=list&catid=$catid&Itemid=565";
    header ('HTTP/1.1 301 Moved Permanently');
    header ('Location: '. $location);
}

答案- 2

我假设您想要的是将URI-1重定向到URI-2

  1. index.php?option=com_adsmanager&view=list&catid=8&Itemid=435
  2. index.php?option=com_adsmanager&view=list&catid=8&Itemid=565

下面的mod_rewrite将允许您将specific URI重定向到其他specific URI。只需在.htaccess文件中添加以下规则即可。

代码语言:javascript
复制
<IfModule mod_rewrite.c>
 Options +FollowSymlinks
 RewriteEngine on
 RewriteCond %{QUERY_STRING} ^option=com_adsmanager&view=list&catid=8&Itemid=435$
 RewriteRule ^/?index\.php$ /index.php?option=com_adsmanager&view=list&catid=8&Itemid=565 [R=301,L]
</IfModule>

答案- 3

如果您想使用'/index.php''/'处理请求,请在您的.htaccess中使用下面的代码。

代码语言:javascript
复制
<IfModule mod_rewrite.c>
 Options +FollowSymlinks
 RewriteEngine on
 RewriteCond %{QUERY_STRING} ^option=com_adsmanager&view=list&catid=8&Itemid=435$
 RewriteRule ^(.*)$ /index.php?option=com_adsmanager&view=list&catid=8&Itemid=565 [R=301,L]
</IfModule>

注意:请勿在单个 .htaccess 文件中同时使用这两个代码。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12326212

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档