CSS not loading after redirect with htaccess rewrite rule

前端 未结 12 2285
自闭症患者
自闭症患者 2020-12-03 05:18

I have the following Short-hand for a user profile url

RewriteRule ^(\\w+)/?$ ./profile.php?name_of_user=$1

The site is styled with the app

12条回答
  •  鱼传尺愫
    2020-12-03 06:14

    When you use this site.com/name_of_user/ you change the working directory on your site from root to name_of_user, therefore the relative path for each file or link on the requested page would become /name_of_user/ instead of /.

    To fix this you need to add additional rule to .htaccess:

    RewriteRule ^name_of_user/(.*)?$ $1
    

提交回复
热议问题