2013-07-08 63 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

[^ /] +和(。*)之間的區別是什麼。我只知道(。*)是一個通配符並接受所有內容。 –

相關問題