2012-06-17 16 views
0

處理所有含site.com/p/QUERY的查詢,但某些用戶錯誤地使用site.com/QUERY作爲請求,並且他們看到404錯誤頁面。使用查詢處理重定向404網址

如何重定向site.com/QUERYsite.com/p/QUERY並通過.htaccess避免404錯誤?

在htaccess教程和問題中找不到任何解決方案。

回答

1

使用此

<Files index.php> 
order allow,deny 
deny from all 
</Files> 
# Turn on URL rewriting 
RewriteEngine On 
Options +FollowSymLinks 
# Installation directory 
RewriteBase/
# Allow these directories and files to be displayed directly: 
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico|img|js|css|media) 
# Rewrite all other URLs to /p/URL 
RewriteRule ^([^/]+)$ /p/$1 [PT,L] 
# Rewrite all other URLs to /p/URL or /p/some.html?var=1&var2=2 
RewriteRule ^(.*)$ /p/$1 [PT,L] 
+0

它需要的index.php的login.php等只需要重定向查詢一些例外。 –

+0

只有GET查詢,你的意思是?像'site.com/p/?a = b'和* not *'site.com/p/a/b'? – h2ooooooo

+0

檢查收到的網址存在的數據庫部分 – luther