此网址
example.com/videos/load.php?cat=video-category
会变成
example.com/videos/video-category
此外,还有分页和限制网址
example.com/videos/load.php?cat=video-category&p=2&limit=20
它会变成
example.com/videos/video-category?page=2&limit=20
此网址也有效
example.com/videos/video-category?page=2
example.com/videos/video-category?limit=20
这是我的htaccess(进入videos
文件夹)
Options +FollowSymLinks
RewriteEngine on
RewriteBase /videos/
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,NE,L]
RewriteRule ^([^/]+)/?$ load.php?cat=$1 [L,QSA]
RewriteRule ^([^/]+)/page/?$ $1 [R=301,L]
RewriteRule ^([^/]+)/page/([1-9][0-9]*)$ load.php?cat=$1&p=$2 [L,QSA]
如何做到这一点..请帮帮我..谢谢..
答案 0 :(得分:2)
想想也许你正在寻找这样的东西?
Options +FollowSymLinks
RewriteEngine on
RewriteBase /videos/
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,NE,L]
RewriteCond %{THE_REQUEST} \ /+videos/load\.php\?cat=([^&\ ]+)&?([^\ ]*)
RewriteRule ^ %1?%2 [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ load.php?cat=$1 [L,QSA]
这符合您提出的问题,但您的规则包含/page/
的内容,这根本不属于您的问题。