【问题标题】:Rewrite rule for subdomain and folders子域和文件夹的重写规则
【发布时间】:2011-06-15 17:43:04
【问题描述】:

我需要为 Apache 编写一个重写规则以用于子域。规则应基于:

subdomain.domain.com => /home/domain/docs/some_folder/file.php?subdomain=subdomain
subdomain.domain.com/edit => /home/domain/docs/some_other_folder/file.php
subdomain.domain.com/dashboard/display/id => /home/domain/docs/some_other_folder2/file.php?param1=display&param2=id

我还在网站上使用 AJAX 调用,这并不容易,正如我通过搜索互联网了解到的那样。所以一些提示也将真的很有帮助。

非常感谢您的帮助! 提前致谢。

【问题讨论】:

    标签: apache mod-rewrite subdomain


    【解决方案1】:

    我要试试这个

    RewriteEngine on
    RewriteBase /
    
    RewriteCond %{HTTP_HOST} !^subdomain.domain.com$
    RewriteRule .* - [L]
    
    RewriteCond %{HTTP_HOST} (.*)
    RewriteRule ^$  /home/docs/some_folder/file.php?subdomain=%1 [L,QSA]
    RewriteRule ^edit$  /home/docs/some_other_folder/file.php [L]
    RewriteRule ^dashboard/(\w+)/(\w+) /home/docs/some_other_folder2/file.php?param1=$1&param2=$2 [QSA,L]
    

    【讨论】:

      猜你喜欢
      • 2012-11-20
      • 1970-01-01
      • 2012-11-22
      • 1970-01-01
      • 1970-01-01
      • 2023-03-13
      • 2016-08-16
      • 2012-02-24
      • 1970-01-01
      相关资源
      最近更新 更多