apache - mod_rewrite pull images from main domain -


i trying template images , css files in sub domain main domain, don't need duplicate everything.

this rule working images in root folder not sub directories.

rewritecond %{http_host} sub.domain.com [nc] rewritecond %{request_filename} \.(jpg|gif|png|css|js|txt|ico|pdf)$ [nc] rewriterule ^(.*) http://www.domain.com/$1 [l,r=301] 

how can modify code specified extensions directs main domain if files in different folders , not in root folder.

try in .htaccess file:

rewritecond %{http_host} ^sub.domain.com$ rewriterule ^(.+\.(?:jpg|gif|png|css|js|txt|ico|pdf))$ http://www.domain.com/$1 [nc,r=permanent] 

that should grab entire request path , filename , append main domain redirect.

if you're using httpd.conf instead, need add forward-slash rewriterule match pattern, after ^ character.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -