Php 500尝试设置.htaccess重定向时出错

Php 500尝试设置.htaccess重定向时出错,php,apache,.htaccess,Php,Apache,.htaccess,我在任何地方都找不到解决问题的办法。似乎什么都不合适 我正在尝试将此代码添加到我的.htaccess: <IfModule mod_rewrite.c> RewriteBase / RewriteEngine On # Check if mobile=1 is set and set cookie 'mobile' equal to 1 RewriteCond %{QUERY_STRING} (^|&)mobile=1(&|$) RewriteRule ^ - [C

我在任何地方都找不到解决问题的办法。似乎什么都不合适

我正在尝试将此代码添加到我的.htaccess:

<IfModule mod_rewrite.c>
RewriteBase /
RewriteEngine On

# Check if mobile=1 is set and set cookie 'mobile' equal to 1
RewriteCond %{QUERY_STRING} (^|&)mobile=1(&|$)
RewriteRule ^ - [CO=mobile:1:%{HTTP_HOST}]

# Check if mobile=0 is set and set cookie 'mobile' equal to 0
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [CO=mobile:0:%{HTTP_HOST}]

# cookie can't be set and read in the same request so check
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [S=1]

# Check if this looks like a mobile device
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC,OR]
RewriteCond %{HTTP:Profile}       !^$

# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST}          !^m\.
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP:Cookie}        !\mobile=0(;|$)
# Now redirect to the mobile site
RewriteRule ^ http://mobile.example.com%{REQUEST_URI} [R,L]

重写基/
重新启动发动机
#检查是否设置了mobile=1,并将cookie“mobile”设置为1
RewriteCond%{QUERY_STRING}(^ |&)mobile=1(&|$)
重写规则^-[CO=mobile:1:%{HTTP_HOST}]
#检查是否设置了mobile=0,并将cookie“mobile”设置为0
RewriteCond%{QUERY_STRING}(^ |&)mobile=0(&|$)
重写规则^-[CO=mobile:0:%{HTTP_HOST}]
#无法在同一请求中设置和读取cookie,请检查
RewriteCond%{QUERY_STRING}(^ |&)mobile=0(&|$)
重写规则^-[S=1]
#检查这是否像一个移动设备
重写条件%{HTTP:x-wap-profile}!^$[或]
重写cond%{HTTP|u USER|u AGENT}“android |黑莓| ipad | iphone | ipod | iemobile | opera mobile | palmos | webos |谷歌机器人移动”[NC,或]
重写cond%{HTTP:Profile}^$
#检查我们是否已经在移动站点上
重写cond%{HTTP_HOST}^m\。
#检查以确保我们之前没有设置cookie
重写cond%{HTTP:Cookie}\mobile=0(;|$)
#现在重定向到移动站点
重写规则^http://mobile.example.com%{REQUEST_URI}[R,L]

每次我将它添加到.htaccess中,都会得到500错误

下面是my.htaccess中的内容:

# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
  order deny,allow
  deny from all
  allow from all
</Limit>
<Limit PUT DELETE>
  order deny,allow
  deny from all
</Limit>
AuthName example.com
AuthUserFile /path/to/file/service.pwd
AuthGroupFile /path/to/file/service.grp
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /blog/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /blog/index.php [L]
</IfModule>


# do not index specified file types
<IfModule mod_headers.c>
  <FilesMatch "\.(doc|docx|xls|xlsx|pdf|ppt|pptx|xml|mp3)$">
    Header set X-Robots-Tag "noindex"
  </FilesMatch>
</IfModule>

Redirect 301 "/blog/2010/03/05/the-power-of-the-radio-jingle/"http://example.com
Redirect 301 "/blog/2010/02/10/how-to-write-for-voice-over/"http://example.com
#-FrontPage-
IndexIgnore.htaccess*/.??**~*#*/HEADER**/README**/\u vti*
命令拒绝,允许
全盘否定
通融
命令拒绝,允许
全盘否定
AuthName example.com
AuthUserFile/path/to/file/service.pwd
AuthGroupFile/path/to/file/service.grp
重新启动发动机
重写库/博客/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/blog/index.php[L]
#不为指定的文件类型编制索引
标题集X-Robots-Tag“noindex”
重定向301“/blog/2010/03/05/收音机铃声的力量/”http://example.com
重定向301“/blog/2010/02/10/如何为画外音写作/”http://example.com
我做错了什么?我以前从未编辑过.htaccess。请帮忙


谢谢

你要知道,拥有一个移动网站对谷歌排名没有好处。您应该有一个响应性网站。请尝试在
重定向301
链接之间添加空格,然后尝试删除
来自arount
/blog/2010/…
重定向链接。另外,您的第一个代码部分缺少
的结束标记。请逐个添加这些段,然后查看哪个段引入了50错误。还要尝试查找错误日志。我发布的.htaccess内容可以正常工作,但可能与文件中显示的内容不完全相同,因为我必须在每行添加4个空格,使其显示为代码。我似乎无法访问我们使用的主机的错误日志。我甚至连一个可以看的电话都没有。只有当我为重定向添加新内容时,才会发生错误。