Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is my .htaccess file redirecting to full server path instead of relative path?
    primarykey
    data
    text
    <p>I've never had a problem with cakePHP before, but something's odd about this server and is causing the redirects in the .htaccess files to behave oddly.</p> <p>CakePHP uses mod_rewrite in .htaccess files to redirect requests to its own webroot folder. The problem is that the redirects are listing the wrong path and causing a 404 error. My CakePHP application, which is stored in the listings directory, has a .htaccess file as follows:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine on RewriteRule ^$ app/webroot/ [R=301,L] RewriteRule (.*) app/webroot/$1 [R=301,L] &lt;/IfModule&gt; </code></pre> <p>(*note that the R=301 causes an external redirect so we can see what is going on from our end. It should really omit this flag and do the redirect internally, transparent to end-users)</p> <p>This is supposed to redirect any request from <code>http://hostname.com/~username/listings/</code> to <code>http://hostname.com/~username/listings/app/webroot/</code> However, rather than simply adding “<code>app/webroot/</code>” to the end as it is supposed to, it is adding the full server path ( <code>/home/username/public_html/listings/app/webroot/</code> ) resulting in the final URL <code>http://hostname.com/home/username/public_html/listings/app/webroot/</code> which is obviously incorrect and triggers a 404 error.</p> <p>The hosting is on a shared hosting account, so that limits what I can do with the settings. I've never seen this happen before, and I'm thinking it's something wrong from the hosting side of things, but if anyone has some helpful suggestions then I can put them to the hosting company as well.</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.
 

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