首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >gitweb重定向至https

gitweb重定向至https
EN

Stack Overflow用户
提问于 2013-02-12 01:24:04
回答 1查看 1.6K关注 0票数 2

我是Apache noob用户,正在尝试自动将对http://.com/gitweb的请求重定向到https://.com/gitweb

我将以下内容设置为/etc/apache2/conf.d/gitweb

代码语言:javascript
运行
复制
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禁止通知

代码语言:javascript
运行
复制
Forbidden
You don't have permission to access /gitweb on this server.
Apache/2.2.22 (Ubuntu) Server at dndo-gamma Port 80

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

My /etc/apache2/ its enabled/000- default与其默认值保持不变

代码语言:javascript
运行
复制
<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>

文件/etc/apache2/sites enabled/ default -ssl在默认的ubuntu/apache2安装中也没有变化。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-12 01:30:38

我通常使用mod_rewrite来完成这些任务:

代码语言:javascript
运行
复制
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteLog "/var/log/apache2/rewrite_log"

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

但这不是编程,而是服务器配置;您可以考虑在serverfault.com上提出这个问题

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14817405

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档