Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
Apache 重写URL搜索引擎优化_Apache_.htaccess_Url_Mod Rewrite_Seo - Fatal编程技术网

Apache 重写URL搜索引擎优化

Apache 重写URL搜索引擎优化,apache,.htaccess,url,mod-rewrite,seo,Apache,.htaccess,Url,Mod Rewrite,Seo,我的网站有这样一个url http://www.mydomain.com/index.php?page=doctors&docid=99 www.mydomain.com/Dr.-John-Smith.html 使用SEO重写 RewriteRule ^doctors/([0-9]+)/(.*).html$ index.php?page=doctors&docid=$1 [L] 我明白了 但是我想要一个像这样更友好的url http://www.mydomain.com/i

我的网站有这样一个url

http://www.mydomain.com/index.php?page=doctors&docid=99
www.mydomain.com/Dr.-John-Smith.html
使用SEO重写

RewriteRule ^doctors/([0-9]+)/(.*).html$ index.php?page=doctors&docid=$1 [L]
我明白了

但是我想要一个像这样更友好的url

http://www.mydomain.com/index.php?page=doctors&docid=99
www.mydomain.com/Dr.-John-Smith.html

如何获取此url。

重写查询字符串

如果你受雇从头开始重新创建现有网站,你可以使用URL重写将旧网站上最流行的20个URL重定向到新网站上的位置。这可能涉及将prod.php?id=20等内容重定向到products/great product/2342,它本身会被重定向到实际的产品页面

Apache的重写规则仅适用于URL中的路径,而不适用于id=20之类的参数。要进行这种类型的重写,需要引用Apache环境变量%
{QUERY\u STRING}
。这可以通过如下方式实现:

RewriteEngine On
RewriteCond   %{QUERY_STRING}           ^id=20$                   
RewriteRule   ^prod.php$             ^products/great-product/2342$      [L,R=301]
RewriteRule   ^products/(.*)/([0-9]+)$  ^productview.php?id=$1             [L]
在本例中,第一条重写规则触发从旧网站URL到新网站URL的永久重定向。第二条规则将新URL重写为显示产品的实际PHP页面

我希望这会有所帮助,请在此处了解有关重写的更多信息:


它的布局非常直截了当。希望这能有所帮助,如果你还有其他问题,请告诉我。谢谢。

尝试这些资源:您能提供更好的解决方案吗?…好的,但是如果url是www.mydomain.com/doctors/13/Dr.-John-Smith.html,请在www.mydomain.com/Dr.John-Smith.html中转换,我需要做什么