Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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重定向到另一个URL_.htaccess_Url_Redirect_Url Rewriting - Fatal编程技术网

.htaccess 使用htaccess将同一域上的一个URL重定向到另一个URL

.htaccess 使用htaccess将同一域上的一个URL重定向到另一个URL,.htaccess,url,redirect,url-rewriting,.htaccess,Url,Redirect,Url Rewriting,我目前正在建立一个新的网站。旧网站的url与新网站的不同。现在我想使用htaccess重定向 在上线之前,我想在本地测试一下我的规则 旧网站使用以下格式的url: www.domain.de/?content=whatevercontent www.domain.de/index.php?content=differentcontentname www.domain.de/nicecontentname 新网站使用以下格式的url: www.domain.de/?content=whate

我目前正在建立一个新的网站。旧网站的url与新网站的不同。现在我想使用htaccess重定向

在上线之前,我想在本地测试一下我的规则

旧网站使用以下格式的url:

www.domain.de/?content=whatevercontent
www.domain.de/index.php?content=differentcontentname
www.domain.de/nicecontentname
新网站使用以下格式的url:

www.domain.de/?content=whatevercontent
www.domain.de/index.php?content=differentcontentname
www.domain.de/nicecontentname
将(在htaccess文件中,使用若干重写规则)重写为以下格式:

www.domain.de/?content=whatevercontent
www.domain.de/index.php?content=differentcontentname
www.domain.de/nicecontentname
我尝试了如下重定向:

Redirect http://domainfolder/?content=whatevercontent http://10.3.10.69/domainfolder/nicecontentname
Redirect http://www.domain.de/?content=whatevercontent http://www.domain.de/index.php?content=differentcontentname
这是行不通的

上线后,它应该是这样工作的:

Redirect http://domainfolder/?content=whatevercontent http://10.3.10.69/domainfolder/nicecontentname
Redirect http://www.domain.de/?content=whatevercontent http://www.domain.de/index.php?content=differentcontentname
…然后被重写到漂亮的url

我的重定向规则不适用,我尝试了我能想到的所有组合,有或没有http,有或没有包含文件夹,使用已经重写的url或实际的url,等等。。
关于这个问题有什么想法吗?

您不能使用重定向指令来管理查询字符串。下面是一个适用于querystring的mod rewrite示例:

RewriteEngine on

RewriteCond %{THE_REQUEST} \s/\?content=this
RewriteRule ^$ /index.php?content=that [L,R]
这将临时重定向到/-content=This/index.php?content=that


要使重定向永久(浏览器可缓存),请将R更改为R=301

谢谢你。你能举一个没有正则表达式的例子吗,仅仅是一个重写规则,然后我可以修改几个URL?这是:RewriteRule/index.php?content=differentcontentname$/?content=whatevercontent吗