2013-12-07 54 views
0

如何將/ pages和/ pages /重定向到索引頁?我想繼續讓人們去/頁/身份證/頁/。我嘗試過的任何嘗試都導致/ pages/ID-of-the-page /被髮送到404頁面。如何使用.htaccess重定向/頁面索引?

下面是我的一些代碼位:

Options +FollowSymLinks 
Options +Indexes 

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^domain.com 
RewriteRule (.*) http://www.domain.com/$1 [R=301,L] 
RewriteCond %{REQUEST_URI} !\.[^./]+$ 
RewriteCond %{REQUEST_URI} !(.*)/$ 
RewriteRule ^(.*)$ http://www.domain.com/$1/ [R=301,L] 

RewriteRule ^pages/([0-9]+)/(.*)$ pages.php?id=$1&page_id=$2 

ErrorDocument 404 http://www.domain.com/404page.php 

回答

0

保持你的.htaccess這樣的:

Options +FollowSymLinks +Indexes -MultiViews 

ErrorDocument 404 http://www.domain.com/404page.php 

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

RewriteCond %{REQUEST_URI} !\.[^./]+$ 
RewriteCond %{REQUEST_URI} !(.*)/$ 
RewriteRule ^(.*)$ http://www.domain.com/$1/ [R=301,L] 

RewriteRule ^pages/([0-9]+)/(.*)$ pages.php?id=$1&page_id=$2 [L,QSA] 

RewriteRule ^pages/?$/[L,R] 
相關問題