1

我在 .htaccess 中有以下代码

ErrorDocument 400 /abc/404

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^/ - [S=2]
    RewriteRule ^abc/(.*)/(.*)$ index.php?aa=$1&bb=$2 [NE,L,QSA]
    RewriteRule ^abc/(.*)$ index.php?aa=$1 [NE,L,QSA]

但是每当我传递错误的网址时,我都会收到以下错误

Not Found

The requested URL /abc/[S=2] was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

如果我删除该行RewriteRule ^/ - [S=2],那么我会收到以下错误

Not Found

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

当我尝试时,http://example.com/abcd/我希望 .htaccess 重定向到http://example.com/abc/404哪个页面

我在做什么错。请帮我。

提前致谢

4

1 回答 1

1

好的,用以下代码替换您的代码:

ErrorDocument 404 /abc/404

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^abc/([^/]+)/([^/]+)/?$ /index.php?aa=$1&bb=$2 [NE,L,QSA]

RewriteRule ^abc/([^/]+)/?$ /index.php?aa=$1 [NE,L,QSA]
于 2013-07-13T11:32:49.787 回答