我试图让一个网站工作对我的测试环境中,但不知何故,无法正常工作。我可以加载正常的索引页,但是当我要访问/页/测试抛出一个错误说法并不存在的页面。我的日志说:
文件不存在:/家庭/ page_url / WWW /页
这实际上是真实的,但它应该得到我的页面控制器,而不是和加载试验方法。
我的.htaccess是这样的:
#打开URL重写 RewriteEngine叙述上 #安装目录 的RewriteBase / #被视为保护隐藏文件 <文件*> 订单拒绝,允许 禁止从所有 < /文件> #被查看保护应用程序和系统文件 重写规则^(?:应用|模块|系统)。\ B * / $ 0 L] #允许存在直接显示的任何文件或目录 的RewriteCond%{} REQUEST_FILENAME!-f 的RewriteCond%{} REQUEST_FILENAME!-d #重写所有其他URL的index.php / URL 重写规则。*的index.php / $ 0 PT]
我的虚拟主机配置是这样的:
<虚拟主机*:80> 服务器名page_url 包括/etc/apache2/vhosts.d/vhco.include 的DocumentRoot/家/ page_url / WWW / #记录 的CustomLog /无功/日志/ apache2的/的access_log共同 错误日志的/ var /日志/的Apache2 / error_log中 #这将改变到你设置的DocumentRoot。 <目录/家/ page_url / WWW /> 对于选项指令#可能的值是无,全部, #或任意组合: #指标包括了FollowSymLinks SymLinksifOwnerMatch ExecCGI多视图 # #注意,多视图必须被显式的指定---所有选项 #不给你。 # #该选项指令既复杂又重要。请参见 #httpd.apache/docs/2.2/mod/core.html#options # 了解更多信息。 选择指标的FollowSymLinks #的AllowOverride控制什么指令可以被放置在.htaccess文件。 #它可以是全部,无,或关键字的任意组合: #选项FileInfo的项AuthConfig极限 设置AllowOverride所有 #控制谁可以从服务器获得资料。 订购允许,拒绝 从所有允许 < /目录> < IfModule alias_module> #重定向:允许你告诉客户有关使用文件 存在于服务器名字空间#,但不是现在。客户端 #将在新位置的文档的新要求。 # 例: #重定向常任/富www.example/bar #别名:地图网络路径到文件系统路径,用于 #不DocumentRoot的生活下访问内容。 # 例: #别名/ webpath /全/文件系统/路径 # #如果你有一个尾随/上/ webpath则服务器将 #要求它是present在URL中。你会也有可能 #需要提供<目录>部分,以允许访问 #文件系统路径。 #ScriptAlias指令:该控制哪个目录包含服务器脚本。 #ScriptAliases基本上相同别名,所不同的是 在目标目录#文件被视为应用和 #服务器时要求,而不是发送到文件运行 # 客户。尾部的规则/适用于ScriptAlias指令 #指令以别名。 的ScriptAlias / cgi-bin目录//无功/网络/本地主机/ cgi-bin目录/ < / IfModule> #/无功/网络/本地主机/ cgi-bin目录应改为你的ScriptAliased #的CGI目录存在,如果有配置。 <目录/家/ page_url / WWW /> 设置AllowOverride无 选择无 订购允许,拒绝 从所有允许 < /目录> < /虚拟主机>
我使用的Gentoo。
任何帮助将是AP preciated。
解决方案 <目录/家/ page_url / WWW /> 设置AllowOverride无本的AllowOverride无禁用的.htaccess 从文件中读取。请参见手动。
另外,请记住,有什么魔力的.htaccess 文件。他们是一个粗糙的解决方法没有完全访问服务器配置。所有这些都是一片Apache配置。如果你有充分的访问服务器的配置,你应该把这样的东西到虚拟主机的配置,而不是的.htaccess 文件。
I'm trying to get a website working on my test environment, but somehow it is not working. I can load the normal index page, but when I want to access /page/test it throws an error saying the page does not exists. My log says:
File does not exist: /home/page_url/www/page
Which is in fact true, but it should got to my Page controller instead and load the test method.
My .htaccess looks like:
# Turn on URL rewriting RewriteEngine On # Installation directory RewriteBase / # Protect hidden files from being viewed <Files .*> Order Deny,Allow Deny From All </Files> # Protect application and system files from being viewed RewriteRule ^(?:application|modules|system)\b.* /$0 [L] # Allow any files or directories that exist to be displayed directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Rewrite all other URLs to index.php/URL RewriteRule .* index.php/$0 [PT]My vhost configuration looks like:
<VirtualHost *:80> ServerName page_url Include /etc/apache2/vhosts.d/vhco.include DocumentRoot "/home/page_url/www/" # Logging CustomLog /var/log/apache2/access_log common ErrorLog /var/log/apache2/error_log # This should be changed to whatever you set DocumentRoot to. <Directory "/home/page_url/www/"> # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # httpd.apache/docs/2.2/mod/core.html#options # for more information. Options Indexes FollowSymLinks # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit AllowOverride All # Controls who can get stuff from this server. Order allow,deny Allow from All </Directory> <IfModule alias_module> # Redirect: Allows you to tell clients about documents that used to # exist in your server's namespace, but do not anymore. The client # will make a new request for the document at its new location. # Example: # Redirect permanent /foo www.example/bar # Alias: Maps web paths into filesystem paths and is used to # access content that does not live under the DocumentRoot. # Example: # Alias /webpath /full/filesystem/path # # If you include a trailing / on /webpath then the server will # require it to be present in the URL. You will also likely # need to provide a <Directory> section to allow access to # the filesystem path. # ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases, except that # documents in the target directory are treated as applications and # run by the server when requested rather than as documents sent to the # client. The same rules about trailing "/" apply to ScriptAlias # directives as to Alias. ScriptAlias /cgi-bin/ "/var/www/localhost/cgi-bin/" </IfModule> # "/var/www/localhost/cgi-bin" should be changed to whatever your ScriptAliased # CGI directory exists, if you have that configured. <Directory "/home/page_url/www/"> AllowOverride None Options None Order allow,deny Allow from All </Directory> </VirtualHost>I'm using Gentoo.
Any help would be appreciated.
解决方案 <Directory "/home/page_url/www/"> AllowOverride NoneThis AllowOverride None disables .htaccess files from being read. See the manual.
Also, please bear in mind that there's nothing magical about .htaccess files. They are a crude workaround for not having full access to the server configuration. All they are is a piece of Apache configuration. If you have full access to the server configuration, you should be putting stuff like this into the vhost configuration, not .htaccess files.
更多推荐
Apache服务器忽略的.htaccess
发布评论