php - .htaccess mapping subdomain to a directory having codeignitor framework -


i know there millons of solution available redirect subdomain directory. still facing problem.

i want map subdomain in following manner

  1. demo1.example.com demo1 dir
  2. demo2.example.com demo2 dir

i using following code

<ifmodule mod_rewrite.c>     rewriteengine on     rewritebase /     rewritecond %{http_host} ^demo1\.example\.com$     #rewritecond %{request_uri} !^/demo1/     rewriterule (.*) /demo1/$1 [l]      rewritecond %{http_host} ^demo2\.example\.com$     rewritecond %{request_uri} !^/demo2/     rewriterule (.*) /demo2/$1 [l] </ifmodule>  

this working fine but getting dir name in url demo1.example.com/demo1/ have used following rewrite rule

rewriterule ^demo1/(.*)$ /$1 [l,nc,r] 

but unable remove demo1 url have codeigniter framework in demo1 dir having following htaccess

<ifmodule mod_rewrite.c>   rewriteengine on   rewritecond %{request_filename} !-f   rewritecond %{request_filename} !-d    rewriterule ^(.*)$ index.php?/$1 [l,qsa]   </ifmodule>  

if have complete installation of framework in each subdirectory , you're not doing kind of dynamic mapping, rewriting urls isn't best solution.

just create virtual host each installation , set server name accordingly.

<virtualhost *:80>   documentroot /var/www/example.com/demo1   servername demo1.example.com </virtualhost>  <virtualhost *:80>   documentroot /var/www/example.com/demo2   servername demo2.example.com </virtualhost> 

depending on kind of hosting you're using, can create virtual hosts in hosting management backend, or check apache 2.2 docs more information.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

android - Pass an Serializable object in AIDL -