2013-02-11 86 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