.htaccess - RewriteCond - What am I doing wrong? -


i'm using opencart seo friendly url's turned on.

that's made .htaccess file this

rewriterule ^sitemap.xml$ index.php?route=feed/google_sitemap [l] rewriterule ^googlebase.xml$ index.php?route=feed/google_base [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !.*\.(ico|gif|jpg|jpeg|png|js|css) rewriterule ^([^?]*) index.php?_route_=$1 [l,qsa] 

but need add in folder exception doesn't rewritten, /emailer

looking around web @ answers did following:

rewritecond %{request_uri} !^/(emailer|js|css)/ [nc] rewriterule ^ - [l] rewriterule ^sitemap.xml$ index.php?route=feed/google_sitemap [l] rewriterule ^googlebase.xml$ index.php?route=feed/google_base [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !.*\.(ico|gif|jpg|jpeg|png|js|css) rewriterule ^([^?]*) index.php?_route_=$1 [l,qsa] 

that makes /emailer/ work, other rewriting doesn't. know i'm doing wrong here?

you insert before main rewriterule.

rewritebase /  rewriterule ^sitemap.xml$ index.php?route=feed/google_sitemap [l] rewriterule ^googlebase.xml$ index.php?route=feed/google_base [l]  rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !^\/(emailer|js|css) [nc] rewritecond %{request_uri} !\.(ico|gif|jpg|jpeg|png|js|css)$ [nc] rewriterule ^([^?]*) index.php?_route_=$1&request_uri=%{request_uri} [l,qsa] 

note: it's not tested, should give idea how it.

later edit:

i have tested code , didn't work. have edited , works now, this:

  1. rewritecond %{request_filename} !-f => if request not real filename
  2. rewritecond %{request_filename} !-d => if request not real directory
  3. rewritecond %{request_uri} !^\/(emailer|js|css) [nc] => if there not directory/file in root starts words emailer/js/css
  4. rewritecond %{request_uri} !\.(ico|gif|jpg|jpeg|png|js|css)$ [nc] => if request not end extension of following ico/gif/jpg/jpeg/png/js/css

notes:

  • to test if need forward slash or not in rewrite rule, append query variable did in modified example , print (on first line after php open tag) in index.php file this:

    print_r($_get['request_uri']); exit;

after done testing, remove request_uri htacces , index.php.

  • always escape forward slash backslash, \ /

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -