使用 mod_rewrite 将目录更改为变量...这有效吗?

发布于 2024-12-24 01:30:51 字数 613 浏览 1 评论 0原文

如果我有一个链接,例如:dashboard/xyz/fff/,并且当页面加载为 loc 且操作可作为变量使用时,我使用 modrewrite 将其更改为仪表板/?loc=xyz&action=fff?

如果是这样,那么这是一个我似乎无法开始工作的具体例子。我的规则是:

RewriteRule ^getclients/([a-z\-]+)$ /dashboard/?action=getclients&module=$1

以及将它们发送到该网址的链接:

<li><a href="getclients/seoanalysis" title="SEO Analysis">SEO Analysis</a></li>

我现在希望位于 .com/dashboard/?action=getclients&module=$1 并使用这些变量加载所需的页面内容。

然而:现在页面重定向到我认为是“正确的页面”,但 CSS 全部损坏了。我只有纯文本。请随意建议另一种方法来实现相同的效果,也可以使用 jQuery 和 Ajax 或其他方法来加载网站的各个部分。

谢谢!

If I have a link, for example: dashboard/xyz/fff/ and I use modrewrite to change it to dashboard/?loc=xyz&action=fff when the page loads are loc and action available as variables to use?

If so, then here's a specific example I can't seem to get to work. My rule as it sits:

RewriteRule ^getclients/([a-z\-]+)$ /dashboard/?action=getclients&module=$1

And the link that is sending them to that url:

<li><a href="getclients/seoanalysis" title="SEO Analysis">SEO Analysis</a></li>

I want now to be at .com/dashboard/?action=getclients&module=$1 and use those variables to load the page content that's needed.

However: Now the page redirects to what I believe is the "right page" but the CSS is all broken. I only have plain text. Feel free to suggest another way to achieve the same effect as well perhaps using jQuery and Ajax or something to load up sections of the site.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

飘落散花 2024-12-31 01:30:51

如果不想使用绝对路径,可以尝试重写图片、javascript、css的请求。也许是这样的:

RewriteCond %{REQUEST_FILENAME} \.(js|css|png|jpe?g|gif)$ [NC]
RewriteRule ^getclients/(.+)$ /dashboard/$1  [L]

If you don't want to use absolute paths, you can try rewriting the requests for images, javascript, and css. Maybe something like this:

RewriteCond %{REQUEST_FILENAME} \.(js|css|png|jpe?g|gif)$ [NC]
RewriteRule ^getclients/(.+)$ /dashboard/$1  [L]
長街聽風 2024-12-31 01:30:51

确保文件位置准确,否则服务器可能会从错误的相对目录发送数据。

Make sure that the file locations are exact, or the server might send the data from the wrong relative directory.

凤舞天涯 2024-12-31 01:30:51

为了从不同的相对路径正确加载 css、图像、js 文件,您应该指定 基本 URL 对于页面上的所有相对 URL,如下所示:

<base href="http://www.example.com/dashboard/" />

For loading css, images, js files properly from a different relative path you should specify a base URL for all relative URLs on a page like this:

<base href="http://www.example.com/dashboard/" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文