Reputation: 23311
My root already has all the css and image files I require
On my hosting, my sub domain has to live inside a folder
root folder
public_html/
index.php
css/
style.php
subdomains/
admin/
.htaccess
index.php
How can I use mod_rewrite in my subdomain to redirect requests for css into my root folder?
FINAL SOLUTION
Thanks! I used Shikhar's answer and modified it to also work with images and js.
RewriteCond %{HTTP_HOST} admin.example.com
RewriteCond %{REQUEST_URI} [css|images|js]/(.*)\.(.*)
RewriteRule (.*) http://www.example.com%{REQUEST_URI} [R=301,NC,L]
Upvotes: 1
Views: 1299
Reputation: 2469
RewriteCond %{HTTP_HOST} xyz.example.com
RewriteCond %{REQUEST_URI} css/style.css
RewriteRule (.*) http://www.example.com%{REQUEST_URI} [R=301,NC,L]
This requires redirect though.
Upvotes: 2
Reputation: 2924
If you have access to the box, why not just create a symbolic link from the subdomain folder to the root folder. You should be able to do this through your file manager or though a shell prompt on the box.
Upvotes: 2