关于ubuntu上codeigniter设置的htaccess问题

时间:2016-04-30 06:40:58

标签: apache .htaccess codeigniter ubuntu

// Log the name of every file in the user's Drive.
 var files = DriveApp.getFiles();
 while (files.hasNext()) {
   var file = files.next();
   Logger.log(file.getName());
 }

这是我的abc.com配置文件,它在服务器上上传了域名和子域名。

    My website open properly when I type `www.abc.com` on browser but when I type `abc.com` it opens page of subdomain which I have hosted which is `admin.abc.com`.

    But the url still says `abc.com`

    Here is my .htaccess code:

    <!-- language: lang-bash -->

        RewriteEngine on
        RewriteBase /
        RewriteCond %{HTTP_HOST} !^www\. [NC]
        RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

    I am using Ubuntu 14.04 with Apache and have configured virtual hosts for both domains.
    Any guidance will be highly appreciated.

这是我对admin.abc.com的配置文件

    <!-- language: lang-bash -->
    # domain: abc.com
    # public: /var/www/abc.com/public_html/

    <VirtualHost *:443>
      SSLEngine On
      SSLCertificateFile /etc/ssl/localcerts/c8d39f3574580de6.crt
      SSLCertificateKeyFile /etc/ssl/localcerts/abc.key
      SSLCertificateChainFile /etc/ssl/localcerts/gd_bundle-g2-g1.crt

      <Directory /var/www>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all
      </Directory>

      # Admin email, Server Name (domain name), and any aliases
      ServerAdmin admin@abc.com
      ServerName  abc.com
      ServerAlias abc.com

      # Index file and Document Root (where the public files are located)
      DirectoryIndex index.html index.php
      DocumentRoot /var/www/abc.com/public_html
      # Log file locations
      LogLevel warn
      ErrorLog  /var/www/abc.com/log/error.log
      CustomLog /var/www/abc.com/log/access.log Combined
    </VirtualHost>

请告知我们上面的conf文件是否有助于确定问题,期待您的回复。

1 个答案:

答案 0 :(得分:0)

您是否正确配置了虚拟主机配置?

如果你能的话,我建议你使用配置文件而不是.htaccess。

(在 / etc / apache2 / sites-enabled sites-available ,如果尚未激活的话)

<VirtualHost *:80>

        # With this configuration when you try to reach both www.abc.com
        # and abc.com it directs you to the same place.
        # If you got a subdomain, you should create a separate .conf file
        # with the correct configurations as well.

        ServerAdmin admins@email.com
        ServerName www.abc.com
        ServerAlias abc.com
        DocumentRoot /var/www/path/to/websites/folder

        # Some more comments...

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # More comments... 
</VirtualHost>

编辑完之后,不要忘记重启Apache服务器:

sudo service apache2 restart 

sudo systemctl restart apache2.service

希望它有所帮助。