【问题标题】:Redirect to subdirectory重定向到子目录
【发布时间】:2011-11-17 01:55:28
【问题描述】:

我在这里和谷歌上搜索过,似乎无法正确。

我在根目录中有一个 .htaccess 文件...我希望我网站的所有地址都转到子目录 (/foo.com/public_html/) 并设置 baseDirectory。

/.htaccess
Options +FollowSymLinks
Options -MultiViews
RewriteEngine on
RewriteBase /foo.com/public_html/

rewritecond %{http_host} ^bar.com [nc]
rewriterule ^(.*)$ http://www.bar.com/$1 [r=301,nc]
rewriterule ^$ /foo.com/public_html/ [nc]

【问题讨论】:

    标签: php apache .htaccess redirect


    【解决方案1】:

    这有帮助吗:

    重写引擎开启 RewriteCond %{HTTP_HOST} ^yoursitename\.com$ 重写规则 (.*) http://www.yoursitename.com/$1 [R=301,L] RewriteRule ^$ yoursub-directoryname[L]

    【讨论】:

    • 将我引导到正确的页面,即子目录中的页面,但是,没有任何样式表或图像是从正确的目录中提取的(它们使用的是相对路径,例如“themes/default/ "
    • 使用 RewriteRule ^$ /foo.com/public_html [L] 修复一切,除了 url 显示 www.bar.com/foo.com/public_html,我需要它来显示 www.bar .com
    • @lostdev 听起来好像您正在使用样式表和图像的相对路径。在这种情况下,您需要使用 base 元素,或者使您的路径相对于根。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-08
    • 1970-01-01
    • 2015-03-09
    • 2019-02-19
    • 1970-01-01
    相关资源
    最近更新 更多