Reputation: 481
I have this code in my .htaccess file which redirects all web pages inside the main_website
folder but currently images are stored in the root
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(blog)/(post|tags|category)/([\w-]+)/?$ main_website/index.php?id=$1&type=$2&unique=$3 [QSA,NC,L]
RewriteRule ^(blog)/(archives)/([0-9]{4})/([0-9]{2})?$ main_website/index.php?id=$1&type=$2&year=$3&month=$4 [QSA,NC,L]
RewriteRule ^(support/knowledgebase)/(article|category|search)/([\w-]+)/?([0-9]+)?$ main_website/index.php?id=$1&type=$2&unique=$3&pagenum=$4 [QSA,NC,L]
RewriteRule ^(account/hosting)/([\w-]+)?$ main_website/index.php?id=$1&p=$2 [QSA,NC,L]
# This will process the /section/(.*) requests, ?section=1 will be appended to query string
RewriteRule ^section\/(.*)?$ main_website/index.php?section=1&id=$1 [L,QSA]
RewriteRule ^/?$ main_website/index.php [L,QSA]
RewriteRule ^([a-zA-Z0-9-/_]+)/?$ main_website/index.php?id=$1 [L,QSA]
How can i alter the above to move my images
folder to the main_website
folder?
Upvotes: 1
Views: 46
Reputation: 785126
Move your images
folder under main_website/
and then you can use these rules in your site root .htaccess:
RewriteEngine On
RewriteRule ^/?$ main_website/index.php [L]
# redirect images to main_website/images/
RewriteRule ^images/.+$ /main_website/$0 [L,NC,R=301,NE]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(blog)/(post|tags|category)/([\w-]+)/?$ main_website/index.php?id=$1&type=$2&unique=$3 [QSA,NC,L]
RewriteRule ^(blog)/(archives)/([0-9]{4})/([0-9]{2})?$ main_website/index.php?id=$1&type=$2&year=$3&month=$4 [QSA,NC,L]
RewriteRule ^(support/knowledgebase)/(article|category|search)/([\w-]+)/?([0-9]+)?$ main_website/index.php?id=$1&type=$2&unique=$3&pagenum=$4 [QSA,NC,L]
RewriteRule ^(account/hosting)/([\w-]+)?$ main_website/index.php?id=$1&p=$2 [QSA,NC,L]
# This will process the /section/(.*) requests, ?section=1 will be appended to query string
RewriteRule ^section\/(.*)?$ main_website/index.php?section=1&id=$1 [L,QSA]
RewriteRule ^([\w/-]+)/?$ main_website/index.php?id=$1 [L,QSA]
Upvotes: 1