【问题标题】:Setting Up Dynamic Sub Domains in CodeIgniter在 CodeIgniter 中设置动态子域
【发布时间】:2014-09-06 09:36:24
【问题描述】:

您好,我目前正在尝试在我的 codeigniter 安装上设置从我的数据库中提取的动态子域,每当我尝试访问子域时,我会收到 403 错误如果我问一个明显的问题,我很抱歉,但我对此很陌生

这是我的虚拟主机设置

     <VirtualHost *:80>
         DocumentRoot /var/www
        ServerName www.example.mobi
        ServerAlias example.mobi
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</VirtualHost>

<VirtualHost *:80>
        DocumentRoot /var/www/subs
        ServerName example.mobi
        ServerAlias *.example.mobi
        <Directory /var/www/subs/>
                # Options +Indexes
                Options FollowSymLinks
                AllowOverride All
        </Directory>
</VirtualHost>

这是我的 .htaccess 文件

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    #this is to allow no indexes
    Options All +Indexes

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule> 
AddType image/x-windows-bmp bmp

这是我在尝试访问子域时看到的错误

 [error] [client x.x.s.x] Directory index forbidden by Options directive: /var/www/subs/

其他信息是我正在使用本指南 http://code.tutsplus.com/tutorials/basecamp-style-subdomains-with-codeigniter--net-16330

为子域设置我的 codeigniter *当我访问域时 “域名.mobi” “域”被回显,因为我已将其设置为回显子域

【问题讨论】:

    标签: php .htaccess codeigniter virtualhost subdomain


    【解决方案1】:

    我找到了一个解决方案,子域虚拟主机只需要指向与主域相同的目录,然后我可以使用子域作为参数

    <VirtualHost *:80>
            **DocumentRoot /var/www**
            ServerName example.mobi
            ServerAlias *.example.mobi
            <Directory /var/www/subs/>
                    # Options +Indexes
                    Options FollowSymLinks
                    AllowOverride All
            </Directory>
    </VirtualHost>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-11
      • 2012-04-01
      • 2016-09-27
      • 2013-12-29
      • 1970-01-01
      • 1970-01-01
      • 2014-05-05
      • 2020-06-19
      相关资源
      最近更新 更多