Access relative CSS/JS files with htaccess rewrite rule

后端 未结 2 404
遥遥无期
遥遥无期 2021-01-22 07:10

I was recently asked if I could make my friends server address more user friendly. His current urls looks like this:

http://wwww.example.com/site/index.php?page=         


        
2条回答
  •  臣服心动
    2021-01-22 07:32

    Is there something I could change or add in my htaccess file to get the css and js files to load with a relative path? If so what would I need to do?

    You could just add the proper relative URI base in your page header:

    
    

    Or you could brute force redirect them using mod_rewrite (not preferable):

    RewriteRule ^(.+)/(admin|css|fonts|ico|include|js)/(.*)$ $2/$3 [L]
    

提交回复
热议问题