2014-01-21 58 views
1

我知道有很多帖子在這裏已經描述了這個完全相同的問題,但我一直在通過他們,並嘗試不同的解決方案無濟於事。htaccess重寫規則給500服務器錯誤

我試圖用最後一個查詢字符串重寫一個URL,並將查詢字符串的值寫入URL的末尾。我已經嘗試了衆多答案中的衆多模式,但是我一直不斷更改URL或500內部服務器錯誤。

這裏是我的htaccess:

RewriteEngine On 
Options +FollowSymlinks 
Options All -Indexes 
ErrorDocument 404 http://domain.com/oh/shit/you/broke/the/internet 
RewriteRule ^oh/shit/you/broke/the/internet$ /404.php [L] 
RewriteRule ^email/([^/]+)/?$ /email/?name=$1 [L,NC,QSA] 

我想http://domain.com/email/?name=blah被改寫爲http://domain.com/email/blah

缺少什麼我在這裏?

================

編輯:

通過日誌看後,我看到了很多以下錯誤:

Invalid command '^email/([^/]+)/?$', perhaps misspelled or defined by a module not included in the server configuration 
Invalid command '^/email/([^/]+)/?$', perhaps misspelled or defined by a module not included in the server configuration 
File does not exist: /home/username/domain.com/email/blah 

下面是完整的htaccess文件,包括修訂後:

RewriteEngine On 
Options +FollowSymlinks 
Options All -Indexes 
ErrorDocument 404 http://domain.com/oh/shit/you/broke/the/internet 
RewriteRule ^oh/shit/you/broke/the/internet$ /404.php [L] 
RewriteCond %{THE_REQUEST} \s/+email/?\?name=([^\s&]+) [NC] 
RewriteRule^/email/%1? [R=301,L] 
RewriteRule ^email/([^/]+)/?$ /email/?name=$1 [L,NC,QSA] 

回答

1

你有語法錯誤。您的代碼沒有RewriteRule關鍵字。

試試這個規則:

RewriteEngine On 
Options +FollowSymlinks 
Options All -Indexes 

RewriteCond %{THE_REQUEST} \s/+email/?\?name=([^\s&]+) [NC] 
RewriteRule^/email/%1? [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^email/([^/]+)/?$ /email/?name=$1 [L,NC,QSA] 
+0

好吧,我做了,確實,忘記一些奇怪的原因的重寫規則。但是,現在回到根本不修改URL ......任何建議? – Amygdala

+0

好吧現在嘗試修改規則。 – anubhava

+0

嗯,它現在正確地重寫了URL,但仍然給出了一個500 IS錯誤。如果這樣簡單的任務需要這麼多的故障排除,我甚至不確定這些頭痛是否值得。大聲笑 – Amygdala