重写.htaccess中的静态文件

发布于 2024-09-28 05:51:56 字数 448 浏览 1 评论 0原文

我在子文件夹 http://example.com/some/other/sub/folder/ 中有应用程序。 和 .htaccess 文件:

    RewriteEngine on    
    RewriteBase /some/other/sub/folder
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?p=$1 [QSA,L]

模板文件包含图像、js 和 css 文件的绝对 URL:/images/header.png/js/common.js 等。

我的问题是具有绝对路径的静态文件不可访问。

谢谢。

I have application in subfolder http://example.com/some/other/sub/folder/.
And .htaccess file:

    RewriteEngine on    
    RewriteBase /some/other/sub/folder
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?p=$1 [QSA,L]

Template files contain absolute URL to the images, js and css files: /images/header.png, /js/common.js etc.

My problem is that static files with absolute paths is not accessible.

Thx.

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

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

发布评论

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

评论(1

忆依然 2024-10-05 05:51:56

原因是,通过绝对 URL 路径 /images/header.png 的引用,您实际上引用了 /images/header.png 而不是 /some/other /sub/folder/images/header.png

使用与 /some/other/sub/folder/ 一起使用的相对 URL 路径作为基本路径。或者使用绝对 URL 路径,例如 /some/other/sub/folder/images/header.png,它们独立于实际的基本路径。

The reason is that with a reference of an absolute URL path /images/header.png you actually reference /images/header.png and not /some/other/sub/folder/images/header.png.

Either use relative URL paths that work with /some/other/sub/folder/ as the base path. Or use absolute URL paths like /some/other/sub/folder/images/header.png that then are independent to the actual base path.

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