【问题标题】:Convert vhost.conf to .htaccess将 vhost.conf 转换为 .htaccess
【发布时间】:2013-12-18 01:40:53
【问题描述】:

大多数人似乎都在询问如何将 .htaccess 转换为 vhost.conf。我需要反过来的东西。我有一个现有的 vhost.conf 文件,看起来像这样......

ServerAlias base1.mydomain.com
ServerAlias base2.mydomain.com
ServerAlias base3.mydomain.com
ServerAlias www.mysite1.co.uk
ServerAlias www.mysite2.co.uk


    RewriteEngine on

    RewriteMap lowercase int:tolower
    RewriteCond %{REQUEST_URI} !^/images/
    RewriteCond %{REQUEST_URI} !^/code/
    RewriteCond %{REQUEST_URI} !^/php/
    RewriteCond %{REQUEST_URI} !^/php-bin/
    RewriteCond %{REQUEST_URI} !^/syles/
    RewriteCond %{REQUEST_URI} !^/js/
    RewriteCond %{REQUEST_URI} !^/jquery/
    RewriteRule ^/(.*)$ /var/www/vhosts/mydomain.com/subdomains/${lowercase:%{SERVER_NAME}}/htdocs/$1

    Alias /scripts/ "/var/www/vhosts/mydomain.com/subdomains/ysite/V4_0_1/scripts/"
    Alias /php/ "/var/www/vhosts/mydomain.com/subdomains/ysite/V4_0_1/php-bin/"

<Files ~ (\.phtml)>
            SetHandler fcgid-script
            FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .phtml
            Options +ExecCGI
            allow from all
    </Files>

    <Files ~ (\.php)>
            SetHandler fcgid-script
            FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
            Options +ExecCGI
            allow from all
    </Files>

    <Files ~ (\.php4)>
            SetHandler fcgid-script
            FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php4
            Options +ExecCGI
            allow from all
    </Files>

Alias /php-bin/ "/var/www/vhosts/mydomain.com/subdomains/ysite/V4_5/php-bin/"
Alias /js/ "/var/www/vhosts/mydomain.com/subdomains/ysite/V4_5/js/"
Alias /css/ "/var/www/vhosts/mydomain.com/subdomains/ysite/V4_5/styles/"
Alias /jquery/ "/var/www/vhosts/mydomain.com/subdomains/ysite/V4_5/jquery/"

我正在尝试将其转换为 .htaccess 文件。从上到下,和serveralias等价的.htaccess命令是什么?

【问题讨论】:

    标签: apache .htaccess vhosts


    【解决方案1】:

    vhost.conf 中的所有内容都不能复制到 .htaccess,因为 .htaccess 中不允许所有指令。

    您可以将此代码放入您的DOCUMENT_ROOT/.htaccess 文件中:

    RewriteEngine on
    
    RewriteCond ${HOST_NAME} [A-Z]
    RewriteCond %{REQUEST_URI} !^/(images|code|php|php-bin|styles|js|jquery)/
    RewriteRule ^(.*)$ http://${lowercase:%{HOST_NAME}}/$1 [L,R]
    
    <Files ~ (\.phtml)>
            SetHandler fcgid-script
            FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .phtml
            Options +ExecCGI
            allow from all
    </Files>
    
    <Files ~ (\.php)>
            SetHandler fcgid-script
            FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
            Options +ExecCGI
            allow from all
    </Files>
    
    <Files ~ (\.php4)>
            SetHandler fcgid-script
            FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php4
            Options +ExecCGI
            allow from all
    </Files>
    

    【讨论】:

      猜你喜欢
      • 2018-07-10
      • 1970-01-01
      • 2017-08-02
      • 2011-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多