2

I am an Apache noob and am trying to automatically redirect requests for http://.com/gitweb to https://.com/gitweb

I've set the following to /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>

However I just keep getting the 403 forbidden notice

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

I don't want all directories hosted by this server to redirect; just the request for gitweb.

My /etc/apache2/sites-enabled/000-default is unchanged from its default

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    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>

The file /etc/apache2/sites-enabled/default-ssl is also unchanged from default ubuntu/apache2 installation.

1 Answer 1

1

usually i use mod_rewrite for these kind of tasks:

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

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

but this is not programming but server-configuration; you might consider asking this question on serverfault.com

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.