Absolute Path for Deployment in a Non-Root Location

后端 未结 8 1360
耶瑟儿~
耶瑟儿~ 2021-01-06 13:22

I typically refer to any assets on my site using absolute path so that I don\'t have to worry about the location of the assets relative to current file.

<         


        
8条回答
  •  既然无缘
    2021-01-06 13:35

    Easy...

    # Assuming mod_rewrite is an option...
    
       # Turn it on!
       RewriteEngine on
    
       # If path is /images/flag.png, connect to /holiday/images/flag.png
       RewriteBase /holiday/
    
    

    Assuming I'm understanding what you mean, this should do you just fine. Point of order, this .htaccess should be in /holiday/

    I do this locally on MAMP for testing a website that's base is in http://localhost:8888/SocialNetwork/ ... If I didn't have that, my absolute paths of, say, /profile would go to http://localhost:8888/profile/ instead of http://localhost:8888/SocialNetwork/profile

提交回复
热议问题