Note that there are some explanatory texts on larger screens.

plurals
  1. PORuby on Rails - .htacces RewriteRule to change image path
    primarykey
    data
    text
    <h1>The situation</h1> <p>I use Carrierwave to upload images to the default upload/ directory. Works fine. When I want to view the images in the front end of my online web server, they don't show.</p> <p>If I use my application in my local setup, the images show.</p> <p>The only difference between my local and web server's setup is that on my server the application is run in subdirectory called "/app". Locally it's in the root directory.</p> <h1>What I have so far</h1> <p>I have this Redirect command in my .htaccess:</p> <pre><code>Redirect 301 /uploads/model/image/54/image.jpg /app/uploads/model/image/54/imgage.jpg </code></pre> <p>I want to formulate a general RewriteRule out of it so that all images which have the path "/uploads/model/image/" are found and redirected to "/app/uploads/model/image/".</p> <p>How can I do that? I've tried several RewriteRules like:</p> <pre><code>RedirectMatch 301 /uploads/(.*) /app/uploads/ </code></pre> <p>or:</p> <pre><code>Redirect 301 /uploads/model/image/(.*) /app/uploads/model/image//$1 </code></pre> <p>or:</p> <pre><code>RewriteRule ^.*/app/uploads/(.*)$ http://%{HTTP_HOST}/uploads/$1 [L,R=301] </code></pre> <h1>What I've read so far</h1> <p>I've read those entries on Stackoverflow:</p> <ul> <li><a href="https://stackoverflow.com/questions/9700990/how-to-change-image-path-using-htaccess">How to change image path using htaccess?</a></li> <li><a href="https://stackoverflow.com/questions/2766443/use-mod-rewrite-to-rewrite-root-to-another-path?lq=1">Use Mod_Rewrite to Rewrite ROOT to Another Path</a></li> <li><a href="https://stackoverflow.com/questions/990392/htaccess-rewrite-to-redirect-root-url-to-subdirectory/990405">.htaccess rewrite to redirect root URL to subdirectory</a></li> </ul> <p>I really have no idea why this happens would be very happy to get any hint, tip or link that could help me out of that.</p>
    singulars
    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