how do i use htaccess to make http requests work properly

Posted by Gabriel on Stack Overflow See other posts from Stack Overflow or by Gabriel
Published on 2010-03-16T13:11:17Z Indexed on 2010/03/16 13:16 UTC
Read the original article Hit count: 220

Filed under:
|

I currently have css and javascript file calls (amongst other things) like the following:

href="/css/default.css" src="/js/ui_control.js"

putting the preceding / in to make the files relative to the root.

This works great when my page is in the root of the domain. However, I'm currently in the middle of transferring my site to a new hosting provider and as such have a temporary URL which is: HOST-IP/~username

As such, all file calls are trying to be called from HOST-IP/css/default.css etc instead of within the ~username sub-folder.

Of course I can wait until the domain name servers propagate but that's beside the point.

How would I go about writing a rule in the .htaccess file that would redirect all file calls that start with a /, from going to HOST-IP/FILE-CALL, and instead to go to HOST-IP/~USERNAME/FILE-CALL. ?

Any ideas?

© Stack Overflow or respective owner

Related posts about apache

Related posts about mod-rewrite