2013-07-08 42 views
1

不工作我在.htaccess自定义404路的ErrorDocument 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这是一个页面

我在做什么错误。请帮帮我。

在此先感谢

+0

是'/ ABC/404'有效的网址?如果是,那么在你的问题中发布完整的.htaccess。 – anubhava

+0

感谢Anubhava。我用完整的代码更新了问题,我正在等待你的帮助。我请求你,如果你能帮助我,上面这将是非常伟大的。谢谢 –

+0

好吧,让我试试。 – anubhava

回答

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] 
+0

。 –

+0

如果你不介意可以向我解释'RewriteRule^- [L]'这一行发生了什么......再次感谢 –

+0

[^ /] +和(。*)之间的区别是什么。我只知道(。*)是一个通配符并接受所有内容。 –

相关问题