【发布时间】:2016-02-03 18:52:47
【问题描述】:
我没有使用 htaccess 的经验,所以我有这个网址:index.php?id=1163&sub=hp 我已经设法使用 htaccess 将第一部分转换为友好的 url:
www.mytesturl.com/index.php?id=1163 进入 www.mytesturl.com/computers/ 但是我需要转换整个网址(两个参数),例如: www.mytesturl.com/index.php?id=1163&sub=hp 进入 www.mytesturl.com/computers/hp/
这是我的 htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?perf=$1
Options -Indexes
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.mytesturl.com
RewriteRule (.*) http://www.mytesturl.com/$1 [R=301,L]
</IfModule>
有人可以指出我正确的方向吗?第二条指令应该在同一行,或者需要添加另一个规则或指令 类似于: RewriteRule (.*) http://www.mytesturl.com/$1 [R=301,L]
【问题讨论】:
标签: apache .htaccess redirect friendly-url