开发者

how do i use htaccess to make http requests work properly

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 try开发者_如何学Cing 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?


I'd suggest changing the references in your HTML to the files to be relative, as this will work either in a sub folder or as the root of the domain.


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

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. ?

Unless you can put a .htaccess at HOST-IP/.htaccess on the new server, you can't do this with .htaccess. It sounds like you're on a shared host, so any approach that'd let you do this with .htaccess would allow you to hijack everyone else's site on the server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜