2013-09-22 161 views

回答

1

第一條規則醜陋的URL重定向到漂亮的URL,同時不改變用戶對瀏覽器的URL看看第二條規則將在內部重定向漂亮的URL回:

Options +FollowSymLinks -MultiViews 

RewriteEngine On 
RewriteBase/

# Redirect /category.php?category=something to /something 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+category\.php\?category=([^&\s]+) [NC] 
RewriteRule^/%1? [R=302,L] 

# Internally forward /something to /category.php?category=something 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.+)/?$ /category.php?category=$1 [QSA,NC,L] 

一旦您確認其按預期工作更改R=302R=301

+0

它工作! thnx很多 –

+0

@ R.David不客氣。 – Prix