使用 htaccess 重写规则重定向后未加载 CSS [英] CSS not loading after redirect with htaccess rewrite rule

查看:27
本文介绍了使用 htaccess 重写规则重定向后未加载 CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下用户个人资料网址的简写

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

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

当我执行 site.com/name_of_user

但不是当我做site.com/name_of_user/

虽然重定向到了正确的页面...

Although the redirect is to the right page...

感谢帮助!

推荐答案

解决这个问题的最简单方法是在 HTML 文件的 中指定 CSS 文件的完整路径.

the easiest way to fix this is to specify the full path to your CSS file in the <head> of the HTML file.

如果你的 mod_rewrite 规则修改了你的 CSS 文件所在的路径,你还想把它放在你的 RewriteRule 之前:

If your mod_rewrite rule is modifying the path to where your CSS file is, you'd also want to place this before your RewriteRule:

RewriteCond %{REQUEST_FILENAME} !-f

这可确保在重写之前请求与文件不匹配.

This makes sure that the request doesn't match a file before rewriting it.

这篇关于使用 htaccess 重写规则重定向后未加载 CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆