我不擅長Apache URL重寫。我想在這裏做一些重寫。Apache URL重寫分頁
http://www.mydomain.com/item/search?words=something&number=1
=>
http://www.mydomain.com/item/search/something/1
而且還應該避免http://www.mydomain.com/search/something/1
=>http://www.mydomain.com/item/search/something/1
(如果沒有/item/
它添加)
這是我重寫代碼。
RewriteRule ^search/(.*)/(.*)/?$ /item/search/$1/$2 [L,R=301]
RewriteRule ^(item/search)/([^/]+)/(\d+)/?$ item/search?words=$2&number=$3
這表明404
:(
UPDATE:這是我所有的.htaccess文件:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteRule ^index\.php$ - [L]
RewriteRule ^comment/(\d+)/?$ /post/comment/$1 [L,R=301]
RewriteRule ^(post/comment)/(\d+)/?$ post/comment?comment=$2
RewriteRule ^rss/(.*)/?$ /item/rss/$1 [L,R=301]
RewriteRule ^(item/rss)/(.*).xml/?$ item/rss.php?rss=$2
RewriteRule ^search/(.*)/(.*)/?$ /item/search/$1/$2 [L,R=301]
RewriteRule ^(item/search)/([^/]+)/(\d+)/?$ item/search?words=$2&number=$3
RewriteCond %{http_host} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
什麼是您在返回一個404瀏覽器的地址欄中鍵入的網址是什麼? –
@Jon Lin,我輸入:'http:// www.mydomain.com/item/search/something/1'返回404. – cj333
這段代碼位於文檔根目錄下的htaccess文件中嗎?當你進入'http://www.mydomain.com/item/search?words = something&number = 1'時會發生什麼? –