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重写规则更改数据库url_.htaccess_Mod Rewrite - Fatal编程技术网

站点更新后需要.htaccess重写规则更改数据库url

站点更新后需要.htaccess重写规则更改数据库url,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我最近更新了我网站上的一些软件,引用数据库的URL也发生了变化。我需要创建一个重写规则,将旧数据库链接转发到它们的新url。我已经尝试了很长一段时间,但运气不好,我决定在我最后一次尝试一条规则后,我会来寻求一些帮助 下面的试验X是一个变量 旧网址: http://www.mysite.com/downloads/index.php?do=listings&catid=X 需要转发到新的url: http://www.mysite.com/downloads/index.php?cate

我最近更新了我网站上的一些软件,引用数据库的URL也发生了变化。我需要创建一个重写规则,将旧数据库链接转发到它们的新url。我已经尝试了很长一段时间,但运气不好,我决定在我最后一次尝试一条规则后,我会来寻求一些帮助

下面的试验X是一个变量

旧网址:

http://www.mysite.com/downloads/index.php?do=listings&catid=X
需要转发到新的url:

http://www.mysite.com/downloads/index.php?categoryid=X

谢谢。

尝试将其添加到文档根目录中的htaccess文件:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^do=listing&catid=(.*)$
RewriteRule ^/?downloads/(index\.php)?$ /downloads/index.php?categoryid=%1 [L,R=301]
或者,如果需要将其放入下载目录:

RewriteEngine On
RewriteBase /downloads/
RewriteCond %{QUERY_STRING} ^do=listing&catid=(.*)$
RewriteRule ^(index\.php)?$ index.php?categoryid=%1 [L,R=301]

你试过什么吗?我试过这个重写规则的许多变体^downloads\/index\.php\?do=listings&catid=/?$http\:\/\/www\.mysite\.com\/downloads\/index\.php\?categoryid=$1[R=301,L]两种方法都试过,但对我都不起作用。Url根本没有重写。解决了问题。您在查询字符串中声明了listing,而它应该是listings。谢谢