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

时间:2015-06-02 09:31:26

标签: php apache .htaccess

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

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

Input              | Expected Result
-------------------------------------
            'nuLL' |             '.'
'        NuLL    ' |             '.'     
            'null' |             '.'
NULL               |             '.'

每次我将它添加到我的.htaccess时,我都会收到500错误。

现在我的.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]

我做错了什么?我以前从未编辑过.htaccess。请帮忙!

谢谢!

0 个答案:

没有答案