2015-07-10 52 views
1

該URL獲得價值與htaccess以及分頁根

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?p=2&limit=20 

(該鏈接也可以)

example.com/videos/video-category?p=2 
example.com/videos/video-category?limit=20 

此外,還有另一個URL根

example.com/videos/load.php?cat=video-category&name=video-name 

它會成爲

example.com/videos/video-category/video-name 

此外,還有分頁&限制網址

example.com/videos/load.php?cat=video-category&name=video-name&p=2&limit=20 

而且,它還將成爲

example.com/videos/video-category/video-name?p=2&limit=20 

(該鏈接也可以)

example.com/videos/video-category/video-name?p=2 
example.com/videos/video-category/video-name?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] 

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] 

如何做到這一點.. PLZ幫我..謝謝..

回答

1

有它這樣:

Options +FollowSymLinks 
RewriteEngine on 
RewriteBase /videos/ 

RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,NE,L] 

RewriteCond %{THE_REQUEST} \s/+videos/load\.php\?cat=([^&\s]+)&name=([^&\s]+)&?(\S*) 
RewriteRule^%1/%2?%3 [L,R=302] 

RewriteCond %{THE_REQUEST} \s/+videos/load\.php\?cat=([^&\s]+)&?(\S*) 
RewriteRule^%1?%2 [L,R=302] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/([^/]+)/?$ load.php?cat=$1&name=$2 [L,QSA] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/?$ load.php?cat=$1 [L,QSA] 
+1

woow不錯的工作......謝謝人.. :) – user3501407