mod_rewrite 的快速小问题(和 Joomla,如果相关的话)
为了回滚能力,我将 Joomla 项目的较新版本推送到现有站点的子目录 (sandbox
) 中。
(我们将它们从 1.0 移至 1.5)
为了打开新上传的版本以供公众访问,我想我只需将 .htaccess
文件添加到现有文档根目录即可,跳过其中的文件:
+- /www
+- index.php # old version
+- ... # files
|
+- .htaccess # htaccess file for redirects
|
+- /sandbox
+- index.php # new version
+- ... # files
我的 .htaccess
文件如下:
# .htaccess for sandbox redirect
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} mysite.com
RewriteCond %{REQUEST_URI} !sandbox/
RewriteRule ^(.*)$ sandbox/$1 [L]
它“工作”,并且现在 http://mysite.com
显示沙箱目录的内容; 但是新版本网站中的链接在其 URL 中包含 sandbox
,这当然仍然有效,但现在我们有了 http://mysite.com/ sandbox/foo/bar
发生了,当我们只想 http://mysite.com/foo/bar
有什么想法吗?
For the sake of roll-back-ability I've pushed a newer version of a Joomla project into a sub-directory (sandbox
) of the existing site.
(We moved them from 1.0 to 1.5)
To open up the newly uploaded version for public access, I figured I would just add an .htaccess
file to the existing documents root, to skip over the files therein:
+- /www
+- index.php # old version
+- ... # files
|
+- .htaccess # htaccess file for redirects
|
+- /sandbox
+- index.php # new version
+- ... # files
My .htaccess
file is as follows:
# .htaccess for sandbox redirect
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} mysite.com
RewriteCond %{REQUEST_URI} !sandbox/
RewriteRule ^(.*)$ sandbox/$1 [L]
It "works", and http://mysite.com
now displays the contents of the sandbox directory; however links within the new version of the site include sandbox
in their URLs, which still work of course, but now we have http://mysite.com/sandbox/foo/bar
happenening, when we only want http://mysite.com/foo/bar
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不将旧站点移至 /oldsite 并将新站点移至根目录?如果您已经测试过并且该网站可以正常工作,则无需搞乱所有重定向。
Why not move the old site to /oldsite and move the new site to the root? If you've tested it and the site works, there is no need to mess around with all the redirecting.
尝试将joomla目录中的configuration.php中的属性$live_site设置为“http://mysite.com”
Try to set property $live_site in configuration.php in your joomla directory to "http://mysite.com"