John Christian De Chavez John Christian De Chavez - 1 year ago 86
Apache Configuration Question

htaccess for new image folder

I'm trying to rewrite the url to another url.

because i already made a subdomain for my images and i want all the url requesting for my images should get in the new image domain.

for example.

old image link -
should get to -

another one

old image link -
should get to -

i have my subfolders in my uploaded folder.
here is my htaccess for now and it seems i cant get it to work.

RewriteEngine on
RewriteRule ^uploaded/(.*)$$1 [R=301,L]

# Use PHP5.4 as default
#AddHandler application/x-httpd-php54 .php

<IfModule mod_rewrite.c>

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L,NC]

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 day"
ExpiresByType text/css "access plus 18000 seconds"
ExpiresByType text/plain "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 18000 seconds"
ExpiresByType application/x-icon "access plus 1 year"

this htaccess is saved to my public html folder. main root of my website.

Answer Source

Create an htaccess in the /uploaded folder and add the following redirect :

Redirect 302 /uploaded/

This will redirect all requests from /uploaded folder to the new destination, eg : to .

You change the redirect status to 301 (permanent redirect) when you are sure it's working ok.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download