2014-01-21 55 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