我是Apache noob,我正在尝试自动将http://.com/gitweb的请求重定向到https://.com/gitweb
我已将以下内容设置为/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 / sites-enabled / 000-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>
文件/ etc / apache2 / sites-enabled / default-ssl在默认的ubuntu / apache2安装中也没有变化。
答案 0 :(得分: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
上提出这个问题