0

我刚刚设法将我的 GitHub 存储库自动播放到http://github.mydomain.com/repositoryname

现在如下:我的大多数项目的根目录中都有样式表、javascripts 等文件夹,例如 href="/css/styles.css" 和 src="/js/scripts.js"。我希望这些重定向/写入到 href="/repositoryname/css/styles.css" 和 src="/repositoryname/js/scripts.js"。

我对htaccess没有一点经验,所以我希望有人能帮助我!

谢谢,伊森

4

2 回答 2

0

解决方案:

We redirect the URL / to /about/:

RewriteEngine on
RewriteRule   ^/$  /about/  [R]

Note that this can also be handled using the RedirectMatch directive:

RedirectMatch ^/$ http://example.com/about/

Note also that the example rewrites only the root URL. That is, it rewrites a request for http://example.com/, but not a request for http://example.com/page.html. If you have in fact changed your document root - that is, if all of your content is in fact in that subdirectory, it is greatly preferable to simply change your DocumentRoot directive, or move all of the content up one directory, rather than rewriting URLs.

这是取自http://httpd.apache.org/docs/trunk/rewrite/remapping.html#page-header的解决方案,请参阅移动的 DocumentRoot 标题。

于 2013-08-16T12:02:47.007 回答
0

为什么不使用相对路径而不是绝对路径。这可以帮助您运行目录中的任何项目。

例如:- ./js/myscript.js 等。

于 2013-08-16T11:38:05.470 回答