Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to change a subdomain's directory with .htaccess?
    text
    copied!<p>I have an image sharing website and I used to have a sub-domain for the images, however I had to delete it, so now I use a real path to the images:</p> <p><strong>old url:</strong></p> <pre><code>http://img.site.com/images/2013/03/abc.jpg </code></pre> <p><strong>new url:</strong></p> <pre><code>http://site.com/files/images/2013/03/abc.jpg </code></pre> <p>The problem with this is that I have a lot of images linked from other websites and search engines that are still using the old URL.</p> <p>The problem with the old sub-domain is that it's directory (<code>public_html/files</code>) and its name (<code>img.</code>) are different, so special configuration was needed to handle that and I got tired of all the problems that it was causing.</p> <p>Now I have created a normal <code>img.</code> sub-domain that is pointing to the <code>public_html/img</code> directory so that no extra configuration needed, however my images are still in the <code>public_html/files</code> directory.</p> <p>I figure all I have to do now is replace the new directory with the old one using .htacess somehow. I don't know if this is possible.</p> <p>My <code>.htaccess</code> is currently:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^img\.site\.com$ [NC] RewriteRule ^(images/.*)$ http://site.com/files/images/$1[R=301,NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteRule ^(.*)$ index.php/$1 [L,QSA] &lt;/IfModule&gt; </code></pre> <p>When I try to call an image from a subdomain I get:</p> <pre><code>Not Found The requested URL /files/images/2013/10/15c100d1da3216850d6cceb4ce57eaab6d26fc92.jpg was not found on this server. img.site.com </code></pre> <p>My error log reports:</p> <pre><code>[Mon Oct 21 02:58:46 2013] [error] [client 85.185.229.221] script '/home/site/domains/site.com/public_html/img/index.php' not found or unable to stat </code></pre>
 

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