我有几个域,我希望通过mod_vhost_alias启用通配符子域
包含在我的httpd.conf中我有以下通用规则:
<VirtualHost [ip here]:80>
ServerName domain1.com
ServerAlias www.domain1.com
DocumentRoot /home/user1/public_html
</VirtualHost>
<VirtualHost [ip here]:80>
ServerName *.domain1.com
VirtualDocumentRoot /home/user1/subdomains/%-3+
</VirtualHost>
<VirtualHost [ip here]:80>
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot /home/user2/public_html
</VirtualHost>
<VirtualHost [ip here]:80>
ServerName *.domain2.com
VirtualDocumentRoot /home/user2/subdomains/%-3+
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
问题是apache完全忽略了带有通配符ServerNames的虚拟主机.对test.domain1.com或test.domain2.com的任何请求都只显示/ home/user1/public_html(根据apache的默认规则)的内容.
/home/user1/subdomains/test并且/home/user2/subdomains/test它们都存在并且包含文件
我的所有域都有一个在bind config中列出的通配符子域,它们指向Vhost规则中指定的相同IP.子域的标准Vhost规则有效,但不是通配符.
一个剪切版本的输出 httpd -S
# httpd -S
VirtualHost configuration:
[ip here]:80 is a NameVirtualHost
default server domain1.com (/etc/httpd/sites/user1:1)
port 80 namevhost domain1.com (/etc/httpd/sites/user1:1)
port 80 namevhost *.domain1.com (/etc/httpd/sites/user1:14)
port 80 namevhost domain2.com (/etc/httpd/sites/user2:1)
port … 或者我应该使用完全不同的服务器?
我正在尝试在Windows Server 2008下的Apache2上配置SVN Web访问以获得不同的写入权限.
我有下一个Apache2 conf:
<Location /svn>
SVNParentPath "E:\SVN"
DAV svn
SVNListParentPath on
AuthType Basic
AuthName "Subversion repositories"
Require valid-user
AuthUserFile svn-auth.txt
AuthzSVNAccessFile svn-acl.txt
</Location>
<Location /svn/foobar>
SVNParentPath "E:\SVN\foobar"
DAV svn
SVNListParentPath on
AuthType Basic
AuthName "Subversion repositories"
Require valid-user
AuthUserFile svn-auth.txt
AuthzSVNAccessFile svn-acl.txt
</Location>
Run Code Online (Sandbox Code Playgroud)
E:\SVN是所有存储库的根目录 - 我想列出所有存储库.它包含E:\SVN\test- 是一个项目存储库.
和E:\SVN\foobar- 是包含E:\SVN\foobar\foo和E:\SVN\foobar\bar- 项目存储库的子根目录
.
文件svn-auth.txt包含由生成的许多用户密码htpasswd.exe
文件svn-acl.txt包含写访问规则,但它不起作用!事件它只包含一个全局权限:
[/]
* = rw
Run Code Online (Sandbox Code Playgroud)
SVN的Apache2配置SVNPath和之间的区别是什么SVNParentPath?也许它会有意义吗?
当然,如果添加组或用户,它也不起作用: …
我正在尝试在cgi-bin中设置一个python脚本,它只返回一个带有content-type:image/png的头文件并返回图像.我试过打开图像并将其返回,print f.read()但这不起作用.
编辑:我正在尝试使用的代码是:
print "Content-type: image/png\n\n"
with open("/home/user/tmp/image.png", "r") as f:
print f.read()
Run Code Online (Sandbox Code Playgroud)
这是在ubuntu服务器10.04上使用apache.当我在chrome中加载页面时,我得到了破碎的图像图像,当我在firefox中加载页面时,我得到了The image http://localhost/cgi-bin/test.py" cannot be displayed, because it contains errors.
我正在使用Apache2和mod_rewrite来隐藏我的查询字符串.这些是有问题的规则.
RewriteCond %{QUERY_STRING} ^query=(.*)$
RewriteRule (.*) /search/%1 [R=301,L]
RewriteRule ^search\/?$ /search/?query=test [R=301,L]
Run Code Online (Sandbox Code Playgroud)
当我访问/search(或/search/)时,我被正确地重定向到/search/?query=test(根据最后的规则)
从那里,RewriteCond而RewriteRule应该踢在和重定向我/search/test,对不对?据我了解了%1我的第一个RewriteRule对应于(.*)在RewriteCond其中应该包含test.
然而,实际发生的是我被重定向到/search/test/?query=test.因此,该规则有效,但由于某种原因附加了查询字符串.QSA选项是以某种方式/某处自动添加的吗?
然后我陷入了一个无限循环的重定向,/search/test?query=test因为第一个RewriteCond又RewriteRule重新启动,再一次又一次......
我究竟做错了什么?!
谢谢!
我不太确定如何阻止谷歌将我的CDN域与我的主域名混合索引.我想通过直接访问CDN域,通过.htaccess重定向到主域.
事实:
谢谢.
我安装了apache2.当我输入http:// localhost时,它会转到文件http://localhost/class/index.php.如何将其更改为http://localhost/index.html或任何其他页面?我会找到哪个文件来执行此操作?谢谢!
我想将多个域重定向到不同的子目录。例如:
如果访问者使用具有HTTP重定向到www.mainme.com的域www.cookie.com,则当访问者到达那里时,Apache会检测到该域并将其重定向到mainme.com/cookie
对于uppy.com也是如此。如果将HTTP重定向到mainme.com,则当用户到达时将其重定向到mainme.com/puppy
可以在.htaccess中完成吗?
使用Linux作为服务器,将/ var / www作为Web文件夹。
现在不使用Virtualhost,而是学习如何使用。
我在位于名为的目录中的.htaccess文件中有此规则clips/:
RewriteRule ^mlk/?$ segment/index.php?clip=1 [R=301,QSA,L]
Run Code Online (Sandbox Code Playgroud)
我想要的是,当有人访问时,http://example.local/clips/mlk他们被重定向到http://example.local/clips/segment/index.php?clip=1
什么实际发生的是,当有人访问example.local/clips/mlk,他们将被重定向到example.local/var/www/example/clips/segment/index.php?clip=1
我不确定为什么会这样做.如果我将重写规则更改为:
RewriteRule ^mlk/?$ /segment/index.php?clip=1 [R=301,QSA,L]
Run Code Online (Sandbox Code Playgroud)
用户被重定向到example.local/segment/index.php?clip = 1,这仍然是不正确的.我不想在这些文件在网站目录树中移动的情况下指定绝对路径.我怎样才能让它相对而不是绝对地工作?
我试图通过使用.htaccess文件来保护我的www文件夹中的目录,该文件没有任何影响所以我改变了行
AllowOverride None
Run Code Online (Sandbox Code Playgroud)
在我的apache2.conf中
AllowOverride All
Run Code Online (Sandbox Code Playgroud)
作为根.
现在我看到这不是正确的方法.当尝试使用重启apache时
/etc/init.d/apache2 restart (or stop and start)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误消息:
[FAIL] Starting web server: apache2 failed!
[warn] The apache2 configtest failed. ... (warning).
Output of config test was:
apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/php5.load: Cannot load /usr/lib/apache2/modules/libphp5.so into server: /usr/lib/apache2/modules/libphp5.so: cannot open shared object file: No such file or directory
Action 'configtest' failed.
The Apache error log may have more information.
Run Code Online (Sandbox Code Playgroud)
我再次将行更改为AllowOverride None,但问题仍然存在.apache2 error.log不包含任何信息.并且配置文件中的第140行是
IncludeOptional mods-enabled/*.load …Run Code Online (Sandbox Code Playgroud)