Codeigniter main domain from Subdirectory: base_url returns sub directory name as well
<p>I want to serve my main domain from a sub-directory in the doc_root in a shared Apache/PHP server. The application is developed using Codeigniter and all the urls are dynamically created using base_url() function. The problem is, all the urls have the name of the subdirectory as well. I want to remove it but don't know how to do it. </p>

<p>base_url produces urls like <code>http://example.com/v2/public_html/page1</code>.
but I want it to produce <code>http://example.com/page1</code>.
Both the above urls serve the correct page however.</p>

<p>This is my directory structure:</p>

<pre><code>|-doc_root
   |-v1 
   |-v2
       |-system
       |-application
       |-public_html
         |-.htaccess
       |-.htaccess
   |.htaccess
</code></pre>

<p>In my config.php file I have setup <code>$config['base_url'] = "http://example.com/";</code>    </p>

<p>.htaccess file in doc_root:</p>

<pre><code>RewriteEngine on
RewriteRule    ^$    v2/public_html/    [L]
RewriteRule    (.*) v2/public_html/$1    [L]
</code></pre>

<p>.htaccess in doc_root/v2:</p>

<pre><code>RewriteEngine on
RewriteRule    ^$    public_html/    [L]
RewriteRule    (.*) public_html/$1    [L] 
</code></pre>

<p>And the .htaccess in doc_root/v2/public_html:</p>

<pre><code>RewriteEngine on
RewriteBase /v2/public_html
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</code></pre>

<p>Please help me to get this resolved.</p>