如何将/ pages和/ pages /重定向到索引页面?我想继续允许人们访问/页面/页面ID /。我尝试过的所有尝试都导致/ pages / ID-of-page /被发送到404页。
以下是我的一些代码:
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 :(得分: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]