php - Rewrite rule causes 'Request exceeded the limit of 10 internal redirects' -


why above line in .htaccess file causes:

rewriterule ^([a-za-z0-9\_\-]+)\/(.*)$ engine/handlers/page_handler.php?handler=$1&page=$2 [qsa,l] 

and error in error_log this:

request exceeded limit of 10 internal redirects due probable configuration error. use 'limitinternalrecursion' increase limit if necessary. use 'loglevel debug' backtrace.

i found lot of posts on stack overflow none of solutions worked me. have centos server cpanel. doesn't happen on server without cpanel.
here .htaccess file:

<files "htaccess_dist">     order allow,deny     deny </files> options -indexes options +followsymlinks directoryindex index.php <ifmodule mod_expires.c>     expiresactive on     expiresdefault "access plus 1 year" </ifmodule> <filesmatch "\.(jpg|jpeg|gif|png|mp3|flv|mov|avi|3pg|html|htm|swf|js|css|ico)$">     fileetag mtime size </filesmatch> <ifmodule mod_php5.c>        php_value memory_limit 64m       php_value register_globals 0         php_value post_max_size 8388608      php_value upload_max_filesize 5242880        php_value display_errors 0 </ifmodule> <ifmodule mod_gzip.c>     mod_gzip_on yes     mod_gzip_dechunk yes     mod_gzip_keep_workfiles no     mod_gzip_minimum_file_size 1000     mod_gzip_maximum_file_size 1000000     mod_gzip_maximum_inmem_size 1000000     mod_gzip_item_include mime ^text/.*     mod_gzip_item_include mime ^application/javascript$     mod_gzip_item_include mime ^application/x-javascript$     # exclude old browsers , images since ie has trouble     mod_gzip_item_exclude reqheader "user-agent: .*mozilla/4\..*\["     mod_gzip_item_exclude mime ^image/.* </ifmodule> <ifmodule mod_deflate.c>     addoutputfilterbytype deflate text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript     browsermatch ^mozilla/4 gzip-only-text/html     browsermatch ^mozilla/4\.[0678] no-gzip     browsermatch \bmsie !no-gzip  <ifmodule mod_headers.c>     header append vary user-agent env=!dont-vary </ifmodule>      setenvifnocase request_uri action\/* no-gzip dont-vary     setenvifnocase request_uri actions\/* no-gzip dont-vary  </ifmodule> <ifmodule mod_rewrite.c>  rewriteengine on rewritebase / rewriterule ^pg\/([a-za-z0-9\_\-]+)$ engine/handlers/page_handler.php?handler=$1&%{query_string} [l] rewriterule ^pg\/([a-za-z0-9\_\-]+)\/(.*)$ engine/handlers/page_handler.php?handler=$1&page=$2&%{query_string} [l] rewriterule ^tag\/(.+)\/?$ engine/handlers/page_handler.php?handler=search&page=$1 [l]   rewriterule ^action\/([a-za-z0-9\_\-\/]+)$ engine/handlers/action_handler.php?action=$1&%{query_string} [l]  rewriterule ^cache\/(.*)$ engine/handlers/cache_handler.php?request=$1&%{query_string} [l]  rewriterule ^services\/api\/([a-za-z0-9\_\-]+)\/(.*)$ engine/handlers/service_handler.php?handler=$1&request=$2&%{query_string} [l]  rewriterule ^export\/([a-za-z]+)\/([0-9]+)\/?$ engine/handlers/export_handler.php?view=$1&guid=$2 [l] rewriterule ^export\/([a-za-z]+)\/([0-9]+)\/([a-za-z]+)\/([a-za-z0-9\_]+)\/$ engine/handlers/export_handler.php?view=$1&guid=$2&type=$3&idname=$4 [l]  rewriterule xml-rpc.php engine/handlers/xml-rpc_handler.php [l] rewriterule mt/mt-xmlrpc.cgi engine/handlers/xml-rpc_handler.php [l] rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^([a-za-z0-9\_\-]+)$ engine/handlers/page_handler.php?handler=$1 [qsa,l]   rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^([a-za-z0-9\_\-]+)\/(.*)$ engine/handlers/page_handler.php?handler=$1&page=$2 [qsa,l] rewriterule . /~user/sub/ </ifmodule> 

when add following rules internal redirects stop , error goes away css , images don't load:

rewritecond %{env:redirect_status} 200 rewriterule ^.* - [l] 

and here httpd.conf file:

include "/usr/local/apache/conf/includes/pre_main_global.conf" include "/usr/local/apache/conf/includes/pre_main_2.conf"   loadmodule bwlimited_module modules/mod_bwlimited.so   include "/usr/local/apache/conf/php.conf" include "/usr/local/apache/conf/includes/errordocument.conf"  errorlog "logs/error_log" defaulttype text/plain scriptaliasmatch ^/?controlpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi scriptaliasmatch ^/?cpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi scriptaliasmatch ^/?kpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi scriptaliasmatch ^/?securecontrolpanel/?$ /usr/local/cpanel/cgi-sys/sredirect.cgi scriptaliasmatch ^/?securecpanel/?$ /usr/local/cpanel/cgi-sys/sredirect.cgi scriptaliasmatch ^/?securewhm/?$ /usr/local/cpanel/cgi-sys/swhmredirect.cgi scriptaliasmatch ^/?webmail/?$ /usr/local/cpanel/cgi-sys/wredirect.cgi scriptaliasmatch ^/?whm/?$ /usr/local/cpanel/cgi-sys/whmredirect.cgi  alias /bandwidth /usr/local/bandmin/htdocs/ alias /img-sys /usr/local/cpanel/img-sys/ alias /java-sys /usr/local/cpanel/java-sys/ alias /mailman/archives /usr/local/cpanel/3rdparty/mailman/archives/public/ alias /pipermail /usr/local/cpanel/3rdparty/mailman/archives/public/ alias /sys_cpanel /usr/local/cpanel/sys_cpanel/  scriptalias /cgi-sys /usr/local/cpanel/cgi-sys/ scriptalias /mailman /usr/local/cpanel/3rdparty/mailman/cgi-bin/ scriptalias /scgi-bin /usr/local/cpanel/cgi-sys/scgiwrap  <directory "/">     options     allowoverride </directory>  <directory "/usr/local/apache/htdocs">     options includes indexes followsymlinks     allowoverride     order allow,deny     allow     </directory>  <files ~ "^error_log$">     order allow,deny     deny     satisfy </files>  <filesmatch "^\.ht">     order allow,deny     deny     satisfy </filesmatch>  <ifmodule log_config_module>     logformat "%h %l %u %t \"%r\" %>s %b \"%{referer}i\" \"%{user-agent}i\"" combined     logformat "%h %l %u %t \"%r\" %>s %b" common      customlog "logs/access_log" common      <ifmodule logio_module>         logformat "%h %l %u %t \"%r\" %>s %b \"%{referer}i\" \"%{user-agent}i\" %i %o" combinedio      </ifmodule>  </ifmodule>  <ifmodule alias_module>     scriptalias /cgi-bin/ "/usr/local/apache/cgi-bin/"  </ifmodule>  <directory "/usr/local/apache/cgi-bin">     allowoverride none     options none     order allow,deny     allow </directory>  <ifmodule mod_log_config.c>     logformat "%h %l %u %t \"%r\" %>s %b \"%{referer}i\" \"%{user-agent}i\"" combined     logformat "%h %l %u %t \"%r\" %>s %b" common     logformat "%{referer}i -> %u" referer     logformat "%{user-agent}i" agent      customlog logs/access_log common  </ifmodule>  <ifmodule mime_module>     typesconfig conf/mime.types     addtype application/x-compress .z     addtype application/x-gzip .gz .tgz  </ifmodule> pidfile logs/httpd.pid lockfile logs/accept.lock listen 0.0.0.0:80 listen [::]:80 user nobody group nobody extendedstatus on serveradmin user@gmail.com servername wdsl.saptik.com loglevel debug  # these can set in whm under 'apache global configuration' timeout 300  serversignature on  <ifmodule prefork.c>  </ifmodule> <ifmodule itk.c>  </ifmodule>  rewriteengine on rewritemap leechprotect prg:/usr/local/cpanel/bin/leechprotect rewritelock /usr/local/apache/logs/rewrite_lock  # set userdir directory virtual hosts, except.. userdir public_html # when following 2 modules loaded <ifmodule mod_ruid2.c> userdir disabled </ifmodule> <ifmodule itk.c> userdir disabled </ifmodule>  # directoryindex set via whm -> service configuration -> apache setup -> directoryindex priority directoryindex index.html.var index.htm index.html index.shtml index.xhtml index.wml index.perl index.pl index.plx index.ppl index.cgi index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml default.htm default.html home.htm index.php5 default.html default.htm home.html  # sslciphersuite can set in whm under 'apache global configuration'  sslpassphrasedialog  builtin sslsessioncache         dbm:/usr/local/apache/logs/ssl_scache sslsessioncachetimeout  300 sslmutex  file:/usr/local/apache/logs/ssl_mutex sslrandomseed startup builtin sslrandomseed connect builtin      listen 0.0.0.0:443     listen [::]:443     addtype application/x-x509-ca-cert .crt     addtype application/x-pkcs7-crl .crl   addhandler cgi-script .cgi .pl .plx .ppl .perl addhandler server-parsed .shtml addtype text/html .shtml addtype application/x-tar .tgz addtype text/vnd.wap.wml .wml addtype image/vnd.wap.wbmp .wbmp addtype text/vnd.wap.wmlscript .wmls addtype application/vnd.wap.wmlc .wmlc addtype application/vnd.wap.wmlscriptc .wmlsc  <location /whm-server-status>     sethandler server-status     order deny,allow     deny     allow 127.0.0.1 ::1 </location>    # suexec supported  include "/usr/local/apache/conf/includes/pre_virtualhost_global.conf" include "/usr/local/apache/conf/includes/pre_virtualhost_2.conf"  # not edit. automatically generated.  if need make change please use include files. namevirtualhost 0.0.0.0:80 namevirtualhost 127.0.0.1:80 namevirtualhost * # not edit. automatically generated.  if need make change please use include files.  <virtualhost 0.0.0.0:80>     servername 0.0.0.0     documentroot /usr/local/apache/htdocs     serveradmin user@gmail.com     <ifmodule mod_suphp.c>         suphp_usergroup nobody nobody     </ifmodule> </virtualhost>   # default vhost unbound ips  <virtualhost *>     servername wdsl.adomain.com     documentroot /usr/local/apache/htdocs     serveradmin user@gmail.com     <ifmodule mod_suphp.c>         suphp_usergroup nobody nobody     </ifmodule> </virtualhost>  # not edit. automatically generated.  if need make change please use include files.   # ssl      # cpanel/whm/webmail/webdisk proxy subdomains  <virtualhost 0.0.0.0:80 127.0.0.1:80>     servername wdsl.adomain.com      serveralias cpanel.* whm.* webmail.* webdisk.*      documentroot /usr/local/apache/htdocs     serveradmin user@gmail.com     <ifmodule mod_suphp.c>         suphp_usergroup nobody nobody     </ifmodule>     rewriteengine on     rewritecond %{http_host} !^wdsl.adomain.com$     rewritecond %{http_host} ^cpanel\.     rewriterule ^/(.*) http://127.0.0.1:2082/$1 [p]      rewritecond %{http_host} !^wdsl.adomain.com$     rewritecond %{http_host} ^webmail\.     rewriterule ^/(.*) http://127.0.0.1:2095/$1 [p]      rewritecond %{http_host} !^wdsl.adomain.com$     rewritecond %{http_host} ^whm\.     rewriterule ^/(.*) http://127.0.0.1:2086/$1 [p]      rewritecond %{http_host} !^wdsl.adomain.com$     rewritecond %{http_host} ^webdisk\.     rewriterule ^/(.*) http://127.0.0.1:2077/$1 [p]      usecanonicalname off </virtualhost>       # cpanel/whm/webmail/webdisk proxy subdomains  <virtualhost 0.0.0.0:443 127.0.0.1:443>     servername wdsl.adomain.com      serveralias cpanel.* whm.* webmail.* webdisk.*      documentroot /usr/local/apache/htdocs     serveradmin user@gmail.com     <ifmodule mod_suphp.c>         suphp_usergroup nobody nobody     </ifmodule>     rewriteengine on     <ifmodule mod_ssl.c>         sslengine on         sslproxyengine on             sslcertificatefile /var/cpanel/ssl/cpanel/cpanel.pem         sslcertificatekeyfile /var/cpanel/ssl/cpanel/cpanel.pem         sslcertificatechainfile /var/cpanel/ssl/cpanel/cpanel.pem      </ifmodule>     rewritecond %{http_host} !^wdsl.adomain.com$     rewritecond %{http_host} ^cpanel\.     rewritecond %{https} on     rewriterule ^/(.*) https://127.0.0.1:2083/$1 [p]      rewritecond %{http_host} !^wdsl.adomain.com$     rewritecond %{http_host} ^webmail\.     rewritecond %{https} on     rewriterule ^/(.*) https://127.0.0.1:2096/$1 [p]      rewritecond %{http_host} !^wdsl.adomain.com$     rewritecond %{http_host} ^whm\.     rewritecond %{https} on     rewriterule ^/(.*) https://127.0.0.1:2087/$1 [p]      rewritecond %{http_host} !^wdsl.adomain.com$     rewritecond %{http_host} ^webdisk\.     rewritecond %{https} on     rewriterule ^/(.*) https://127.0.0.1:2078/$1 [p]      usecanonicalname off </virtualhost>  #jk  loadmodule jk_module modules/mod_jk.so jkworkersfile /usr/local/apache/conf/workers.properties # put jk logs jkloglevel debug # select log format jklogstampformat "[%a %b %d %h:%m:%s %y]" # jkoptions indicate send ssl key size jkoptions +forwardkeysize +forwarduricompat -forwarddirectories # jkrequestlogformat set request format jkrequestlogformat "%w %v %t" # send xhtml requests glassfish jkmount /*.xhtml worker1 # send domain requests glassfish jkmount /domain/* worker1  <virtualhost 0.0.0.0:80>     servername sub.domain.com     serveralias www.sub.domain.com     documentroot /home/sub/public_html/sub     serveradmin webmaster@sub.domain.com     usecanonicalname off     customlog /usr/local/apache/domlogs/sub.domain.com combined     customlog /usr/local/apache/domlogs/sub.domain.com-bytes_log "%{%s}t %i .\n%{%s}t %o ."     ## user user # needed cpanel::apacheconf     userdir enabled user     <ifmodule mod_suphp.c>         suphp_usergroup user user     </ifmodule>     <ifmodule !mod_disable_suexec.c>         <ifmodule !mod_ruid2.c>             suexecusergroup user user         </ifmodule>     </ifmodule>     <ifmodule mod_ruid2.c>         rmode config         ruidgid user user     </ifmodule>     <ifmodule itk.c>         # more information on mpm itk, please read:         #   http://mpm-itk.sesse.net/         assignuserid user user     </ifmodule>     scriptalias /cgi-bin/ /home/user/public_html/sub/cgi-bin/      accessfilename .htaccess </virtualhost>   <virtualhost 0.0.0.0:80>     serveradmin admin@domain.com     servername  domain.com            proxyrequests off           <proxy *>              order deny,allow              allow           </proxy>         proxypass / http://0.0.0.0:8080/           proxypassreverse / http://0.0.0.0:8080/            <location />         order allow,deny         allow         </location>         errorlog logs/glassfish-apache-error_log          customlog logs/glassfish-apache-access_log common       </virtualhost>  include "/usr/local/apache/conf/includes/post_virtualhost_global.conf" include "/usr/local/apache/conf/includes/post_virtualhost_2.conf" 

the rule redirects itself. try following rule before yours:

rewriterule ^engine/handlers/page_handler.php  -  [l] 

this end redirect rules if server serves page_handler.php script.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -