【问题标题】:.htaccess and rewrite sub domains.htaccess 和重写子域
【发布时间】:2014-01-16 05:15:20
【问题描述】:

我有一个在自定义框架上运行的网站。但是我想添加一个网关子域来处理特定的请求。以及处理 api 请求的 api 子域。

现在有一个复杂的文件夹结构:

-application
-config
-subs (subdomain folder)
  - gateway
  - api
-library
-public
  .htaccess [2]
-scripts
-tmp
.htaccess [1]

现在我想让http://gateway.example.com 重定向到 subs > 网关,并将 http://api.example.com 重定向到 subs > api 文件夹。

第一个.htaccess [1]

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/scripts/
    RewriteRule ^(.*)$ /public/$1 [L]
 </IfModule>

第二个 .htaccess [2] (我认为不需要在这里发布,但你更新了;)

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^popup/   - [L]
RewriteRule ^img/   - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$              index.php?url=$0 [PT,L]
</IfModule>

我认为我应该更改第一个 .htaccess [1]。但是为了什么?

请帮帮我。

【问题讨论】:

    标签: apache .htaccess mod-rewrite redirect


    【解决方案1】:

    这可以通过像这样为gateway 子域正确设置VirtulDomain 来解决:

    DocumentRoot /home/example/domains/example.com/public_html/subs/gateway
    

    【讨论】:

    • 嗨,anubhava,感谢您的快速回复。但我仍然收到内部服务器错误,请求时:gateway.example.com/test.html
    • 我有一个错误,刚刚修复。你现在可以试试吗?
    • 由于某种原因它不起作用。仍然是内部服务器错误。主站点(公开)仍在运行。
    • 更进一步,现在它为我们提供了一个 Not Found。但实际上网关文件夹中有一个名为:test.html 的文件。请求网址:gateway.example.com/test.html 为我提供了未找到的信息。
    • 那么您写了http://gateway.example.com to redirect to subs &gt; gateway 您需要首先确保您的原始目标URI 工作正常。你确定gateway.example.comDocumentRoot 是一样的www.example.com
    猜你喜欢
    • 2010-12-29
    • 2011-05-15
    • 2011-02-04
    • 2014-03-17
    • 1970-01-01
    • 1970-01-01
    • 2011-05-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多