【发布时间】:2012-12-28 15:41:29
【问题描述】:
我是 URL 重写的新手。
我在主页上有一个锚文本,点击后会打开另一个页面。单击链接时在浏览器中显示的目标 url 是 http://example.com/index.php?p=one/two/three/pdp&abc=436
相反,我想在 URL 中显示 http://example.com/index.php?p=shopping/shop/ipad/pdp&abc=436.
所以本质上我正在查看的是 URL 中的替换 一/二/三
到 购物/购物/ipad
我想要网址http://example.com/index.php?p=one/two/three/pdp&abc=436 看起来像http://example.com/index.php?p=shopping/shop/ipad/pdp&abc=436。
请注意,我有 14,000 页,因此无法在任何地方进行物理更改。 我希望使用 url 重写来实现这一点。因此,在根目录中,我已将以下几行添加到 .htaccess 中。
RewriteEngine On
RewriteRule ^shopping/shop/ipad/?$ one/two/three/pdp [NC,L]
但这会导致内部服务器错误。
如何才能显示更好的网址? 谢谢
【问题讨论】:
-
RewriteRule不能直接用于查询字符串。您需要查看RewriteCond。 -
查看 apache 错误日志。确保 mod_rewrite 已启用。 (
a2enmod rewrite)