【发布时间】:2017-01-06 13:46:44
【问题描述】:
我有一个网站可以重定向到带有查询字符串的页面。我需要使该网址对 SEO 友好。网址是
http://www.tasteofkochi.com/dine-detail.php?a=51-fort-kochi-mattanchery
我需要它看起来像
http://www.tasteofkochi.com/dine-detail/51-fort-kochi-mattanchery
我想删除 '.php' 扩展名,然后将 '?a=' 替换为 '/'
谁能告诉我如何实现它。
【问题讨论】:
-
.htaccess重写服务器端,例如,您将https://example.com/foo/bar放在网络浏览器地址栏中,网络服务器将其发送到https://example.com/index.php?foo=bar。您可以执行从https://example.com/index.php?foo=bar到https://example.com/foo/bar的 301 重定向 - 类似于RewriteCond %{QUERY_STRING} a=70$后跟RewriteRule (.*) /dine-detail/? [R=301,L](以执行重定向。
标签: php apache .htaccess mod-rewrite