移动的.htaccess内容转换成虚拟主机,性能 [英] Move .htaccess content into vhost, for performance

查看:179
本文介绍了移动的.htaccess内容转换成虚拟主机,性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在想,如果能表现,如果我将.htaccess文件的内容到的Apache2的虚拟主机文件中增加了吗?

I was wondering if performance can be increased if I move .htaccess file content into a vhost file of apache2?

这是我的.htaccess的内容

This is the content of my .htaccess

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteCond %{SERVER_NAME} ^([^.]+\.[^.]+)$ [NC]
  RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

  # we check if the .html version is here (caching)
  RewriteRule ^$ index.html [QSA]
  RewriteRule ^([^.]+)$ $1.html [QSA]
  RewriteCond %{REQUEST_FILENAME} !-f

  # no, so we redirect to our front web controller
  RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

如果这样做是一个好主意,凡在虚拟主机声明我应该把上面的内容?

If doing so is a good idea, where in the vhost declaration should I place above content?

谢谢!

推荐答案

如果你要编辑的虚拟主机配置文件(S)你应该总是这样做的可能性。该的.htaccess越来越PTED与它是由你的网站的每一个请求,除$ P $,而在另一方面,vhost.conf为PTED上的httpd重启/重装只跨$ P $。

If you have the possibility to edit vhost-configuration file(s) you should always do so. The .htaccess is getting interpreted with every single request which is made to your site while on the other hand the vhost.conf is only interpreted on httpd restart/reload.

您可以设置的选项目录的指令 - 例如:

You could set the Options in Directory-directive - e.g.:

<Directory /usr/local/apache2/htdocs/somedir>
Options +FollowSymLinks +ExecCGI
</Directory>

<VirtualHost [...]>
[...]
RewriteEngine On

RewriteCond %{SERVER_NAME} ^([^.]+\.[^.]+)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f

# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</VirtualHost>

另外一起来看看这 wikipost 在apache.org - 尤其是部分的如果要我,而我不应该使用.htaccess文件?

Also take a look at this wikipost on apache.org - especially the section When should I, and should I not use .htaccess files?

这篇关于移动的.htaccess内容转换成虚拟主机,性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆