我拥有的 我有一个域configuration为指向我的服务器。 当我去我的领域,让我们说: example.com 它将我redirect到: http://104.286.131.72/mysitefolder/index.php? 当然,它显示我正确的网站。 我有这个Apache和一个名为/etc/apache2/sites-enabled/000-default.conf与这个内容的文件: <VirtualHost *:80> DocumentRoot /var/www/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> <VirtualHost *:80> DocumentRoot /var/www/mysitefolder/ ServerName example.com ServerAlias www.example.com </VirtualHost> 我想要的是 当我去我的领域: example.com 它将我redirect到: http://example.com/index.php? 并向我展示相同的网站。 我怎样才能做到这一点? UPDATE1 试图将第二个块更改为@imvikasmunjal答案,我敢这样做: The requested URL /mysitefolder/index.php was not found on this server. /var/log/apache2/access.log文件说: 190.126.199.244 – – [25/Apr/2016:01:43:43 -0400] "GET /mysitefolder/index.php? HTTP/1.1" […]
$ apache2 -v Server version: Apache/2.4.7 (Ubuntu) Server built: Jan 14 2016 17:45:23 我的Ubuntu版本是14.04。 我正在修复/etc/apache2/sites-available/000-default.conf上的一些东西,然后下一次我重新启动Apache,我不断得到这个奇怪的错误: $ sudo service apache2 reload * Reloading web server apache2 [fail] * * The apache2 configtest failed. Not doing anything. Output of config test was: env: apache2ctl: No such file or directory 我还恢复了000-default.conf所有更改,但问题没有得到解决。 我不明白我是如何造成这个问题,也不知道如何解决这个问题。 帮助将不胜感激。 最新的Apache错误日志: [Sun Jun 05 11:50:26.341221 […]
我有一个文件www.example.org.conf ,我想将httpredirect到https 。 问题是该文件不完全正确的工作。 <VirtualHost *:80> ServerName example.org ServerAlias www.example.org DocumentRoot "/var/www/example.org/www" CustomLog /var/www/example.org/www.access.log common ErrorLog /var/www/example.org/www.error.log RewriteEngine on RewriteCond %{SERVER_NAME} =example.org [OR] RewriteCond %{SERVER_NAME} =www.example.org RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] </VirtualHost> redirect实际上是从letsencrypt自动生成的,但是这是问题所在。 在http://www.example.org中键入将按照预期redirect到https://www.example.org 。 问题是当你inputhttp://example.org时 ,它将显示apache的默认页面,而不是redirect到https。 当我inputhttps://example.org或https://www.example.org (显示我想要的页面)时,我可以validationSSL conf是否正常工作。 所以我得出结论,问题在于mod_rewrite 。 但是,我不知道什么是错的。 事实上,我遵循相同结构的其他虚拟主机按预期工作。 请帮我弄清楚我的网站configuration有什么问题。 顺便说一句,我使用Debian的Apache2。
我有两个域名: domain1.com domain2.com 我有一个Apache 2服务器,一个文件根/svr. 我想要发生以下情况: domain1.com路由到相当于/svr/examplepath/thisisadir/param/domain1 domain2.com路由到相当于/svr/examplepath/thisisadir/param/domain2 我已经尝试在/svr,使用带有RewriteEngine的.htaccess ,在站点中使用VirtualHost声明 – 可用于每个主机名,并简单地使用301redirect。 不过,我不能使用简单的301,因为用户仍然应该在浏览器中看到domain1.com 。 即domain1.com/about-this-site应映射到/svr/examplepath/thisisadir/param/domain1/about-this-site. 我不能得到RewriteEngine将主机名路由到他们各自的端点,任何意见将不胜感激。 我目前正在尝试在服务器根目录下的.htaccess中使用HTTP_HOST ,但重写规则仍然没有生效。 Ilmiont
我只允许访问/htdocs/reserved/目录从192.168.1.193到192.168.1.254(.193 – > .254)的IP地址。 我已经写在httpd.conf这段代码: <Directory /htdocs/reserved/> Order Deny, Allow Deny from all Allow from 192.168.1.193/254 </Directory> 停止之后,Apache将不会重新启动并引发此exception: 名为Apache的服务报告了以下错误:指定的networking掩码无效。 问题似乎是掩码192.168.1.193/254 。 我也试过了: <Directory /htdocs/reserved/> Order Deny, Allow Deny from all Allow from 192.168.1.193 192.168.1.254 </Directory> 有用! Apache的启动,但我不知道是否所有的IP地址范围内允许访问目录或只有192.168.1.193和192.168.1.254被允许。 官方的文档缺乏明确的信息(或者我太愚蠢了解它)。 问题是:允许一个IP地址范围访问目录的正确方法是什么? 方面说明:我已经使用私人范围只是例如。 谢谢你,对我的英语感到抱歉。
所以我不确定这种设置是怎么调用的,所以我很难对它进行谷歌search,看看我是否在正确的方向前进。 我目前有什么 我有一个CMS,有一个虚拟主机www.example.com ,pipe理界面这是在一个子域admin.www.example.com 。 我需要的 现在除了CMS,我需要有一个论坛平台,并运行。 这是如何设立的 www.example.com – > CMS www.example.com/advice – >论坛 这是一个像这样可能与Apache? 细节 我在apache 2.4.6上运行centos7。 我现在的虚拟主机就像下面这样 <VirtualHost *:80> ServerName example.com DocumentRoot /www/example.com SetEnv ADMIN_DOMAIM 0 <Directory "/www/example.com> AllowOverride All Options FollowSymLinks </Directory> php_value mbstring.func_overload 0 DirectoryIndex index.php </VirtualHost> <VirtualHost *:80> ServerName admin.example.com DocumentRoot /www/example.com SetEnv ADMIN_DOMAIN 1 <Directory /www/example.com> AllowOverride All […]
比方说,我有一个目录,我想限制访问的方式,以便用户可以访问目录只有上午6时至下午6时。 我知道如何通过使用PHP(使用time()%86400 )来做到这一点。 但我可以完全使用Apache的内置函数(.htaccess或服务器apache2.conf)或其他mods吗?
我已经尝试使用Apache FilesMatch指令来处理所有文件为PHP失败。 使用这个<FilesMatch "\.html$"> ,我能够处理特定的文件扩展名为PHP,但我无法find一个包含所有文件types的指令,没有扩展名。 我如何configurationApache来parsingPHP内容的所有文件?
我在CentOS上看到的所有使用Apache的Rewrite规则的教程都展示了如何启用.htaccess,然后将规则放在那里,这要求在httpd.conf启用AllowOverRide All来使用www目录。 从安全angular度来看,我认为保持.htaccess禁用并将重写放入httpd.conf(或… / sites-enabled / example.net.conf)会更好。 的确,这是Apache手册的build议, 何时(不)使用.htaccess 。 使用httpd.conf进行重写是否有很好的理由并不常见?
我为一个小企业设置了一个新域名,他们希望https://在他们的域名中,因为他们以前的主机默认提供了它(以前的主机也有旧域名)。 当我在/etc/apache2/sites-available/设置我的服务器configuration块时,我将所有请求转发到新的域,如下所示: <VirtualHost *:80> # example2 – NEW, example1 – OLD # Simply redirecting all traffic to https ServerName example2.com ServerAlias www.example2.com ServerAlias example1.com ServerAlias www.example1.com Redirect 301 / https://example2.com/ </VirtualHost> <IfModule mod_ssl.c> <VirtualHost *:443> ServerAdmin [email protected] ServerName example2.com DocumentRoot /var/www SSLEngine on SSLCertificateFile /path/to/ssl/example2/example2.crt SSLCertificateKeyFile /path/to/ssl/example2/example2.com.key SSLCACertificateFile /path/to/ssl/example2/example2.com-bundle </VirtualHost> <VirtualHost *:443> # If the […]