apache - htaccess rewrite rule doesnt work in mobile browser -


ive been trying make mobile version of site , redirecting users htaccess file.

my site uses rewrite rules before clean urls, works great. when try exact same rule redirect mobile.php instead of index.php, 500 internal server error.

here code:

rewriteengine on  rewritecond %{http_user_agent} #detect mobile browsers here... rewriterule ^([^/]*)[/]*([^/]*)$ /mobile.php?r=$1&id=$2 [l]  rewritecond %{script_filename} !-f rewritecond %{script_filename} !-d rewriterule ^([^/]*)[/]*([^/]*)$ /index.php?r=$1&id=$2 [l] 

can see problem?

yes -- line post invalid few reasons:

rewritecond %{http_user_agent} #detect mobile browsers here... 
  1. comment #detect mobile browsers here... can first non-empty character in line -- comment cannot start in middle of line.

  2. because of #1, line incomplete -- should have "condition pattern" part, missing (you have comment instead). see the docs full/correct syntax

  3. you may enter rewrite loop in rule (a lot of people forgetting after mod_rewrite rewrite, goes iteration, , if not insert proper condition (rewritecond) may loop forever -- apache break after reaches limit, point remains).


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -