Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 如何使用htaccess仅替换url的一部分?_.htaccess_Url_Replace - Fatal编程技术网

.htaccess 如何使用htaccess仅替换url的一部分?

.htaccess 如何使用htaccess仅替换url的一部分?,.htaccess,url,replace,.htaccess,Url,Replace,我需要将生成的joomla url修改为另一个,htaccess似乎是一个很好的方法。只是我对它不太熟悉:/ 我需要创建以下url: http://www.site.com/component/uddeim/?task=new&recip=190&nouserlist=141 http://www.site.com/community/messages?task=new&recip=190&nouserlist=141 重写到此url中: http://www

我需要将生成的joomla url修改为另一个,htaccess似乎是一个很好的方法。只是我对它不太熟悉:/

我需要创建以下url:

http://www.site.com/component/uddeim/?task=new&recip=190&nouserlist=141
http://www.site.com/community/messages?task=new&recip=190&nouserlist=141
重写到此url中:

http://www.site.com/component/uddeim/?task=new&recip=190&nouserlist=141
http://www.site.com/community/messages?task=new&recip=190&nouserlist=141

?task=new&recip=190&nouserlist=141
假设您的意思是最终用户将在浏览器中输入
/component/uddeim/?…
,请使用:

RewriteEngine On
RewriteRule ^component/uddeim/? http://example.com/community/messages [L,QSA,R=301]

QSA
标志表示原始查询字符串应附加到新URL,并将其保存在任何位置。

它不起作用:(我仍然在地址栏中看到旧URL…可能我解释错了。我的意思是,生成的链接是:当我单击链接时,我想要它(或将其复制并粘贴到浏览器中)它转换为:PS。两个链接都可以工作并打开同一页。@user1010703因此您需要重定向,而不是不可见的重写。由于它们是同一页,因此上面的重写规则在工作时将不会产生可见的效果。添加
[R=301]
flag to redirect.THANK..它被重定向了,但不是正确的url..从此:它被重定向到:我做错了什么吗?我想是我做的!:)RewriteEngine On RewriteRule ^component/uddeim/?[L,QSA,R=301]谢谢!!ps/我想给你一个答案的分数,但它不会让我这么做,因为我的声誉很低:P