苦苦于重写URL

时间:2015-06-20 15:14:48

标签: .htaccess url mod-rewrite url-rewriting

我有一个名为pc_services.html的页面,我想重写网址,以便显示为pc_and_network_specialists / services.html

我认为这段代码会做我想要的:

RewriteRule ^pc_and_network_specialists/services.html&  pc_services.html

虽然我获得了访问禁止错误,但我的网址显示为

*domain*/E:/xampp/htdocs/pc_and_network_specialists/services.html

而不是

*domain*/pc_and_network_specialists/services.html

1 个答案:

答案 0 :(得分:0)

您可以改用:

RewriteEngine On

# Redirect old to new
RewriteCond %{THE_REQUEST} pc_services\.html
RewriteRule ^ /pc_and_network_specialists/services.html [R,L]

# Rewrite new to old
RewriteRule ^pc_and_network_specialists/services.html$ /pc_services.html [L]