.htaccess - 500 Internal Server Error

Salexes

I want to redirect user based on their user agent to a specific websites.

Right now my .htaccess file is looking like this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


# END WordPress
RewriteCond %{HTTP_USER_AGENT} opera
RewriteCond %{QUERY_STRING} articleid=(?:[0-9]{1,3}|1000)

<If "%{QUERY_STRING} == 'articleid=001'">
RewriteRule ^$ http://m.example.com/ [L,R=302]
</If>
<ElseIf "%{QUERY_STRING} == 'articleid=002'">
RewriteRule ^$ http://m.example2.com/ [L,R=302]
</ElseIf>
<ElseIf "%{QUERY_STRING} == 'articleid=003'">
RewriteRule ^$ http://m.example3.com/ [L,R=302]
</ElseIf>
<ElseIf "%{QUERY_STRING} == 'articleid=004'">
RewriteRule ^$ http://m.example4.com/ [L,R=302]
</ElseIf>
etc...

Right now i get a 500 Internal Server Error error when it is entered like this. How to fix it to make it workable?

Best regrards, salexes

anubhava

Try changing these rules to traditional mod_rewrite rule syntax and keep redirects before default WP rule:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_USER_AGENT} opera
RewriteCond %{QUERY_STRING} (^|&)articleid=articleid=001(&|$) [NC]
RewriteRule ^$ http://m.example.com/? [L,R=302]

RewriteCond %{HTTP_USER_AGENT} opera
RewriteCond %{QUERY_STRING} (^|&)articleid=articleid=002(&|$) [NC]
RewriteRule ^$ http://m.example2.com/? [L,R=302]

RewriteCond %{HTTP_USER_AGENT} opera
RewriteCond %{QUERY_STRING} (^|&)articleid=articleid=003(&|$) [NC]
RewriteRule ^$ http://m.example3.com/? [L,R=302]

RewriteCond %{HTTP_USER_AGENT} opera
RewriteCond %{QUERY_STRING} (^|&)articleid=articleid=004(&|$) [NC]
RewriteRule ^$ http://m.example4.com/? [L,R=302]

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

</IfModule>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

.htaccess/.htpasswd 500 Internal Server Error

From Dev

.htaccess - Clean URL, 500 Internal Server Error

From Dev

.htaccess RewriteRule 500 Internal Server Error

From Dev

.htaccess file gives 500 internal server error

From Dev

.htaccess/.htpasswd 500 Internal Server Error

From Dev

Apache - htaccess 500 internal server error

From Dev

What is wrong with my .htaccess? 500 Internal server error

From Dev

Redirect subfolder content to different domain with htaccess (500 Internal Server Error)

From Dev

HTACCESS 500 internal server error website gone down

From Dev

.htaccess - Clean URLs prevent 500 internal server error

From Dev

Internal server error 500 with new rule in .htaccess in Prestashop

From Dev

Htaccess rewrite url gives 500 Internal server error

From Dev

500 Internal Server Error for sub domain using htaccess in SilverStripe 3.1

From Dev

.htaccess 500 internal server error when adding simple 301 redirect

From Dev

Htaccess rewrite url gives 500 Internal server error

From Dev

Internal server error 500 with new rule in .htaccess in Prestashop

From Dev

(AltoRouter) .htaccess file leads to 500 Internal Server Error

From Dev

Internal Server Error (500)

From Dev

.htaccess rewriterule 500 internal error

From Dev

htaccess resulting in 500 internal error

From Dev

Internal Server Error .htaccess

From Dev

CakePHP 500 Internal Server Error

From Dev

500 Internal server error scrapy

From Dev

500 Internal Server Error Heroku

From Dev

Internal Server 500 Error - Django

From Dev

Ajax: 500 Internal Server Error

From Dev

nginx 500 Internal Server Error

From Dev

AJAX 500 (Internal Server Error)

From Dev

NginX 500 (Internal Server) Error

Related Related

HotTag

Archive