我有这样的网址,我想从
清理我的网址http://www.125books.com/move-other-bk?file=Advanced.C%20sharp%20.Programming.pdf
到
http://www.125books.com/move-other-bk/file/Advanced.C%20sharp%20.Programming.pdf
贝洛是我的htaccess文件
Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / ## hide .php extension snippet # To externally redirect /dir/foo.php to /dir/foo RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1 [R,L] # To internally forward /dir/foo to /dir/foo.php RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{DOCUMENT_ROOT}/$1.php -f RewriteRule ^(.*?)/?$ $1.php [L]
答案 0 :(得分:0)
让您的代码如下:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(move-other-bk)\?(file)=([^\s&]+) [NC]
RewriteRule ^ /%1/%2/%3? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^(move-other-bk)/(file)/([^/.]+)/?$ /$1?$2=$3 [L,QSA,NC]
## hide .php extension snippet
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*?)/?$ $1.php [L]