【问题标题】:Use custom path for naked main domain (except path) in apche2在 apache2 中为裸主域(路径除外)使用自定义路径
【发布时间】:2020-02-20 10:45:50
【问题描述】:

我有以下 apache 配置文件

<VirtualHost *:443>
    ServerName example.io
    ServerAlias *.*

    Alias /static /var/www/user/master/workbench/workbench/static
    DocumentRoot /var/www/user/master/workbench/workbench/static

    # Redirect naked URL to the specified URL
    # RedirectMatch ^/$ http://other-example.io

    # Load custom index page as homepage
    AliasMatch ^/$ /var/www/user/master/workbench/scnv_home

    WSGIDaemonProcess example.io   processes=1 threads=5 python-path=/var/www/user/master/workbench:/home/ubuntu/.virtualenv/app/lib/python2.7/site-packages/
    WSGIProcessGroup example.io
    WSGIScriptAlias / /var/www/user/master/workbench/workbench/wsgi.py

    <Directory /var/www/user/master/workbench/workbench/static >
        Order deny,allow
        Allow from all
        AllowOverride All
    </Directory>

</VirtualHost>

该域用于使用 WSGI 访问 Django 站点,RedirectMatch 配置选项用于将用户重定向到其他域。

https://example.io        -> Redirects to http://other-example.io
https://example.io/path    # Served by Django

现在我想显示一个自定义的index.html 页面,而不是将用户重定向到其他域。

为此,我尝试使用AliasMatch 选项指向存在index.html 文件的目录,但它仍然由Django 提供服务并提供404 Django 页面。

如果 url 有路径,我如何设置 apache 以通过 Django 处理请求,否则加载自定义索引页面?

【问题讨论】:

  • 我想知道您是否使用 SSL?
  • 你想知道什么?
  • 我想知道您是否使用 SSL?
  • 是的,我确实使用 SSL。

标签: apache apache2


【解决方案1】:

&lt;VirtualHost _default_:443&gt;

#JkMount /* worker1

DocumentRoot "/var/www/html"

ProxyPass /error/404.html !

ErrorDocument 404 /error/404.html

ProxyPass / "ajp://localhost:443/

ProxyPassReverse / "ajp://localhost:443/

ServerName yourdomain.com:443

尝试在您的ssl.conf 文件中使用上述代码,希望对您有所帮助...!!!!

【讨论】:

  • 根据您的要求在上述配置中进行修改,如文件路径、文档根目录、错误文档、代理密码。
猜你喜欢
  • 2015-04-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-17
  • 2017-06-19
  • 2022-01-26
相关资源
最近更新 更多