2013-02-11 47 views
0

我是一个Apache小白,我试图自动重定向HTTP请求://.com/gitweb到https://.com/gitweb的GitWeb重定向到https

我设置以下到/ etc /apache2/conf.d/gitweb

Alias /gitweb /usr/share/gitweb 
<Directory /usr/share/gitweb> 
    Options FollowSymLinks +ExecCGI 
    AddHandler cgi-script .cgi 
    Redirect gitweb https://<myserver>.com/gitweb 
    SSLRequireSSL 
</Directory> 

不过,我只是不断收到403禁止通知

Forbidden 
You don't have permission to access /gitweb on this server. 
Apache/2.2.22 (Ubuntu) Server at dndo-gamma Port 80 

我不希望此服务器重定向托管的所有目录;只是gitweb的请求。

我的/ etc/apache2的//000-默认为它的默认

<VirtualHost *:80> 
    ServerAdmin [email protected] 

    DocumentRoot /var/www 
    <Directory /> 
      Options FollowSymLinks 
      AllowOverride None 
    </Directory> 
    <Directory /var/www/> 
      Options Indexes FollowSymLinks MultiViews 
      AllowOverride None 
      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> 

不变启用站点,文件/ etc/apache2的/ /默认情况下,SSL也从Ubuntu默认不变启用站点-/ apache2安装。

回答

1

通常我使用mod_rewrite对于这些类型的任务:

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteLog "/var/log/apache2/rewrite_log" 

    RewriteRule ^/gitweb/(.*) https://%{SERVER_NAME}/gitweb/%1 [R] 

但这不是编程,但服务器的配置;你可以考虑问这个问题serverfault.com