RewriteEngine On
RewriteBase /
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+page\.php\?article=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ page.php?article=$1 [L,QSA]
1 回答
将此代码放在
DOCUMENT_ROOT/.htaccess
文件中: