2013-05-31 61 views
1

是否有可能創建一個漂亮的網址,而無需觸摸文件本身?例如:創建一個漂亮的網址而不接觸文件

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] 

回答

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]