Note that there are some explanatory texts on larger screens.

plurals
  1. POMod rewrite - remap site root
    primarykey
    data
    text
    <p>I'm having some problems with mod rewrite in the following configuration (simplified version):</p> <pre><code>/index.php /public/ /public/file.txt </code></pre> <p>I need to remap the site root to the /public so i can call /file.txt for every existing file in /public. In the same time, every non-existing file should be remapped to index.php which is not in the /public folder.</p> <p>I have previously solved this issue by using:</p> <pre><code>RewriteCond %{DOCUMENT_ROOT}/public%{REQUEST_URI} -f RewriteRule ^(.*)$ public/$1 [L] RewriteRule ^(.*)$ index.php?$1 [L] </code></pre> <p>the only problem is that it only works if the site and the .htaccess is in the server root directory. What I need is to make it work if the site is in the /codeigniter/ directory</p> <pre><code>/codeigniter/index.php /codeigniter/public/ /codeigniter/public/file.txt </code></pre> <p>which obviously fails because </p> <pre><code>/public%{REQUEST_URI} </code></pre> <p>translates into</p> <pre><code>/public/codeigniter/public/ which doesn't exist </code></pre> <p>I've tried setting the rewriteBase to the /codeigniter/ directory but I think it only strips the dir in the rewrite Rule and not in the RewriteCond since it doesn't work.</p> <p>I think that an idea would be to map everything to the /public folder and in /public/.htacces re-remap non existent files to ../index.php (not sure if it's possible)</p> <p>I would really apreciate any help you can give me with this, since it's an older problem I'm constantly facing. <strong>Ideally</strong>, the path should not be hardcoded in the .htaccess so I can easily move or rename the site folder without changing the .htaccess</p> <p>Cheers</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload