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]

しかし、間違ったURLを渡すたびに以下のエラーが発生します

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 に答える