apache - htaccess issue configuring pseudo style virtual host -


i having issues htaccess file. trying use rewrite rules create pseudo style virtual host on apache shared hosting server.

i have 3 domains under 1 account , want achieve following:

  • if not rule exists go root (domain1.co.uk)
  • if domain2.co.uk set directory d1
  • if domain3.co.uk set directory d2
  • irrespective of domain, if www. missing, add it.

the file have @ moment follows:

rewriteengine on rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l]  rewritecond %{http_host} ^domain2.co.uk$ [or]  rewritecond %{http_host} ^www.domain2.co.uk$ [or]  rewriterule ^(.*)$ /d2/$1   rewritecond %{http_host} ^domain3.co.uk$ [or]  rewritecond %{http_host} ^www.domain3.co.uk$ [or]  rewriterule ^(.*)$ /d3/$1 

this looked working except domains seem go first rule , direct /d2. result if domain1.co.uk, domain2.co.uk or domain3.co.uk entered go domain1.co.uk.

any thoughts?

you put [or] on each of second rules. instructs apache next rule if 1 fails. when both rules fail, goes next one, non-existent. rewriterule gets triggered in case. equivalent doing if or somethingelse or, nonsensical.

remove [or] second rule , should work.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -