apache - Htaccess rewrite one file to another one - coexistence with general rewrite -


in htaccess file have:

# 1) redirect non-www www  rewritecond %{http_host} !^www.mydomain.com$ [nc] rewriterule ^(.*)$ http://www.mydomain.com/$1 [l,r=301]    # 2) redirect files in root equivalent files in subfolder #    @ same time changing htm extension html  rewritecond %{request_uri} !^/new/ rewriterule ^(.*)\.htm$ /new/$1.html [l] rewritecond %{request_uri} !^/new/ rewriterule ^(.*)$ /new/$1 [l] 

now need add rewrite condition specific file. requests of type: http://www.mydomain.com/downloads/myfile1.zip

and need rewrite to: http://www.mydomain.com/new/downloads/myfile2.zip

can tell me rule add?

you can insert new rule zip file handling , add exception zip file in subsequent rules:

rewritecond %{http_host} !^www\.mydomain\.com$ [nc] rewriterule ^(.*)$ http://www.mydomain.com/$1 [l,r=301]   rewriterule ^downloads/myfile1\.zip$ /new/downloads/myfile2.zip [l,nc,r=301]  # 2) redirect files in root equivalent files in subfolder #    @ same time changing htm extension html  rewritecond %{request_uri} !^/(new/|myfile2\.zip) [nc] rewriterule ^(.*)\.htm$ /new/$1.html [l]  rewritecond %{request_uri} !^/(new/|myfile2\.zip) [nc] rewriterule ^(.*)$ /new/$1 [l] 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -