1

是否可以创建一个漂亮的 url 而不必触摸文件本身?例如:

http://sawebdev01/company/news-events/press-releases/press-release/?pr=168#.Uajh_kCyBSK

并将其转换为:

http://sawebdev01/company/news-events/press-releases/pr/168

我试过这个,它似乎不起作用:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{THE_REQUEST} /company/news-events/press-releases/press-release/?pr=([^&]+) [NC]
RewriteRule .*             /company/news-events/press-releases/press-release/pr/%1? [R=301,L]
4

1 回答 1

0

试试这个代码:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} \s(/company/news-events/press-releases)/press-release/\?pr=([^&]+) [NC]
RewriteRule ^ %1/pr/%1? [R=302,L]

RewriteRule ^(company/news-events/press-releases)/pr/([^/]+)/?$ /$1/press-release?pr=$2 [L,NC,QSA]
于 2013-06-01T12:53:29.490 回答