与mod_rewrite的和mod_userdir问题 [英] Problems with mod_rewrite and mod_userdir

查看:162
本文介绍了与mod_rewrite的和mod_userdir问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让跑,别人把一个网站的本地副本。该网站被部署和功能,我试图让一个开发版本我的public_html目录下成立。

该网站使用了mod_rewrite通过执行各种初始化步骤网关脚本来重定向所有流量。我有一个奇怪的问题,其中包括链接的的.php 延伸的工作,但那些没有与下面的异常死亡:

警告:未知:未能打开流:在未知在线0致命错误没有这样的文件或目录:未知:失败需要开放'重定向:/~george/site/.fiona/core/ gateway.php'(include_path中=':在/ usr /共享/ PHP:在/ usr /共享/梨')在未知在线0

下面是.htaccess文件的副本(编辑我的本地安装)

  RewriteEngine叙述在
选择了FollowSymLinks +的RewriteBase /〜乔治/网站/
的RewriteCond%{REQUEST_URI}!.fiona /核心/ gateway.php
。重写规则^ \\菲奥娜/(即[az] +)/([A-ZA-Z0-9 _ \\ - ] +)(\\ PHP)$ .fiona /核心/ gateway.php组= $ 1目的地= $ 2 \\? .PHP [L,QSA]
的RewriteCond%{REQUEST_URI}!.fiona /核心/ gateway.php
重写规则^([AZ] +)/?([A-ZA-Z0-9 _ \\ - ] +)(。\\ PHP)$ .fiona /核心/ gateway.php组= $ 1目的地= $ 2 \\ .PHP [L ,QSA]
的RewriteCond%{REQUEST_URI}!.fiona /核心/ gateway.php
重写规则^([A-ZA-Z0-9 _ \\ - ] +)?(\\ PHP)$ .fiona /核心/ gateway.php目的地= $ 1 \\ .PHP [L,QSA]

下面是我在我的mod_rewrite的日志中看到

本地主机/〜乔治/网站/登陆

  127.0.0.1  -   -  [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#211168d0 / subreq](3) [perdir /家庭/乔治/的public_html /网站/]条每DIR preFIX:/home/george/public_html/site/login.php  - >的login.php
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#211168d0 / subreq](3)[perdir /家庭/乔治/的public_html /网站/]应用模式'^ \\菲奥娜/(即[az] +)/([A-ZA-Z0-9 _ \\ - ] +)$(\\ PHP)?'到URI的login.php
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#211168d0 / subreq](3)[perdir /家庭/乔治/的public_html /网站/]带每DIR preFIX:/home/george/public_html/site/login.php - >的login.php
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#211168d0 / subreq](3)[perdir /家庭/乔治/的public_html /网站/]应用模式'^([AZ] +)/([A-ZA-Z0-9 _ \\ - ] +)(。\\ PHP)$?'到URI的login.php
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#211168d0 / subreq](3)[perdir /家庭/乔治/的public_html /网站/]带每DIR preFIX:/home/george/public_html/site/login.php - >的login.php
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#211168d0 / subreq](3)[perdir /家庭/乔治/的public_html /网站/]应用模式'^([A-ZA-Z0-9 _ \\ - ] +)(\\ PHP)$?'到URI的login.php
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#211168d0 / subreq](4)[perdir /家庭/乔治/的public_html /网站/] RewriteCond指令:输入='/〜乔治/网站/ login.php中'模式='!菲奥娜/核心/ gateway.php'=>匹配
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#211168d0 / subreq](2)[perdir /家庭/乔治/的public_html /网站/]重写的login.php' - >'?.fiona /核心/ gateway.php目的地=的login.php'
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#211168d0 / subreq](3)拆分URI = .fiona /核心/ gateway.php?目的地=的login.php - > URI = .fiona /核心/ gateway.php,ARGS =目标=的login.php
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#211168d0 / subreq](3)[perdir /家庭/乔治/的public_html /网站/]加上每DIR preFIX:.fiona /核心/ gateway.php - > /home/george/public_html/site/.fiona/core/gateway.php
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#211168d0 / subreq](2)[perdir /家庭/乔治/的public_html /网站/]试图取代preFIX /家庭/乔治/的public_html /网站/与/〜乔治/网站/
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#211168d0 / subreq](5)条匹配preFIX:/家庭/乔治/的public_html /网站/ .fiona /核心/ gateway.php - > .fiona /核心/ gateway.php
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#211168d0 / subreq](4)添加SUBST preFIX:.fiona /核心/ gateway.php - > /~george/site/.fiona/core/gateway.php
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#211168d0 / subreq](1)[perdir /家庭/乔治/的public_html /网站/]内部重定向与/~george/site/.fiona/core/gateway.php [内部重定向]
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#21103668 /初始](3)[perdir /家庭/乔治/的public_html /网站/]应用模式'^ \\菲奥娜/(即[az] +)/([A-ZA-Z0-9 _ \\ - ] +)$(\\ PHP)?'到URI重定向:/~george/site/.fiona /core/gateway.php
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#21103668 /初始](3)[perdir /家庭/乔治/的public_html /网站/]应用模式'^([AZ] +)/([A-ZA-Z0-9 _ \\ - ] +)$(\\ PHP)?'到URI重定向:/~george/site/.fiona/core/gateway .PHP
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#21103668 /初始](3)[perdir /家庭/乔治/的public_html /网站/]应用模式'^([A-ZA-Z0-9 _ \\ - ] +)(\\ PHP)$?'到URI重定向:/~george/site/.fiona/core/gateway.php
127.0.0.1 - - [05 /月/ 2011:08:47:37 --0400] [本地主机/ SID#20f41ce8] [摆脱#21103668 /初始](1)[perdir /家庭/乔治/的public_html /网站/]通过重定向:/~george/site/.fiona/core/gateway.php

本地主机/〜乔治/网站/ login.php中

  127.0.0.1  -   -  [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224bf668 /初始](3) [perdir /家庭/乔治/的public_html /网站/]条每DIR preFIX:/home/george/public_html/site/login.php  - >的login.php
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224bf668 /初始](3)[perdir /家庭/乔治/的public_html /网站/]应用模式'^ \\菲奥娜/(即[az] +)/([A-ZA-Z0-9 _ \\ - ] +)$(\\ PHP)?'到URI的login.php
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224bf668 /初始](3)[perdir /家庭/乔治/的public_html /网站/]带每DIR preFIX:/home/george/public_html/site/login.php - >的login.php
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224bf668 /初始](3)[perdir /家庭/乔治/的public_html /网站/]应用模式'^([AZ] +)/([A-ZA-Z0-9 _ \\ - ] +)(。\\ PHP)$?'到URI的login.php
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224bf668 /初始](3)[perdir /家庭/乔治/的public_html /网站/]带每DIR preFIX:/home/george/public_html/site/login.php - >的login.php
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224bf668 /初始](3)[perdir /家庭/乔治/的public_html /网站/]应用模式'^([A-ZA-Z0-9 _ \\ - ] +)(\\ PHP)$?'到URI的login.php
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224bf668 /初始](4)[perdir /家庭/乔治/的public_html /网站/] RewriteCond指令:输入='/〜乔治/网站/ login.php中'模式='!菲奥娜/核心/ gateway.php'=>匹配
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224bf668 /初始](2)[perdir /家庭/乔治/的public_html /网站/]重写的login.php' - >'?.fiona /核心/ gateway.php目的地=的login.php'
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224bf668 /初始](3)拆分URI = .fiona /核心/ gateway.php?目的地=的login.php - > URI = .fiona /核心/ gateway.php,ARGS =目标=的login.php
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224bf668 /初始](3)[perdir /家庭/乔治/的public_html /网站/]加上每DIR preFIX:.fiona /核心/ gateway.php - > /home/george/public_html/site/.fiona/core/gateway.php
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224bf668 /初始](2)[perdir /家庭/乔治/的public_html /网站/]试图取代preFIX /家庭/乔治/的public_html /网站/与/〜乔治/网站/
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224bf668 /初始](5)条匹配preFIX:/家庭/乔治/的public_html /网站/ .fiona /核心/ gateway.php - > .fiona /核心/ gateway.php
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224bf668 /初始](4)添加SUBST preFIX:.fiona /核心/ gateway.php - > /~george/site/.fiona/core/gateway.php
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224bf668 /初始](1)[perdir /家庭/乔治/的public_html /网站/]内部重定向与/~george/site/.fiona/core/gateway.php [内部重定向]
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224c97b8 /初始/ REDIR#1](3)[perdir /家庭/乔治/的public_html /网站/]条每DIR preFIX:/home/george/public_html/site/.fiona/core/gateway.php - > .fiona /核心/ gateway.php
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224c97b8 /初始/ REDIR#1](3)[perdir /家庭/乔治/的public_html /网站/]应用模式'^ \\菲奥娜/(即[az] +)/([A-ZA-Z0-9 _ \\ - ] +)$(\\ PHP)?'到URI.fiona /核心/网关.PHP
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224c97b8 /初始/ REDIR#1](4)[perdir /家庭/乔治/的public_html /网站/] RewriteCond指令:输入='/〜乔治/网站/ .fiona /核心/ gateway.php'模式='!菲奥娜/核心/ gateway.php'=>不匹配
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224c97b8 /初始/ REDIR#1](3)[perdir /家庭/乔治/的public_html /网站/]条每DIR preFIX:/home/george/public_html/site/.fiona/core/gateway.php - > .fiona /核心/ gateway.php
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224c97b8 /初始/ REDIR#1](3)[perdir /家庭/乔治/的public_html /网站/]应用模式'^([AZ] +)/ - (\\ PHP)?([A-ZA-Z0-9 _ \\] +)$'到URI.fiona /核心/ gateway.php
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224c97b8 /初始/ REDIR#1](3)[perdir /家庭/乔治/的public_html /网站/]条每DIR preFIX:/home/george/public_html/site/.fiona/core/gateway.php - > .fiona /核心/ gateway.php
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224c97b8 /初始/ REDIR#1](3)[perdir /家庭/乔治/的public_html /网站/]应用模式'^([A-ZA-Z0-9 _ \\ - ] +)(\\ PHP)$?'到URI.fiona /核心/ gateway.php
127.0.0.1 - - [05 /月/ 2011:08:58:18 --0400] [本地主机/ SID#222fdce8] [摆脱#224c97b8 /初始/ REDIR#1](1)[perdir /家庭/乔治/的public_html /网站/]通过/home/george/public_html/site/.fiona/core/gateway.php

没有的.php 扩展的链接似乎使初始重定向成功,但是,由于某种原因,他们似乎是无法重新路由到的绝对路径。

我绝不是mod_rewrite的专家,所以很可能是其他的问题在这里。任何想法将是巨大的。

修改
基于马吕斯的答案,我相信我已经缩小下来到一个问题与mod_userdir结合的mod_rewrite。该网站移动到/ var / WWW解决此问题。我还是想在我的public_html目录得到这个工作。

修改
马吕斯使我更接近的站点解决方案启用。原来,问题是多视图(允许Apache以跨preT指数的index.php)没有为用户目录启用。添加以下到我的默认站点启用(在/ etc / apache2的/ / 000-默认启用的站点 - )解析扩展名为.php的问题,但禁用mod_rewrite的。

 &ltDirectory /家庭/ * /的public_html>
    选择指数多视图了FollowSymLinks
    设置AllowOverride无
    为了允许,拒绝
    所有允许
&LT /目录>

启用我的整个网站如下

 &ltVirtualHost *:80>
    站长的ServerAdmin @本地    的DocumentRoot的/ var / WWW
    &ltDirectory />
        有FollowSymLinks
        设置AllowOverride无
    &LT /目录>
    &ltDirectory在/ var / WWW />
        选择指数多视图了FollowSymLinks
        设置AllowOverride无
        为了允许,拒绝
        所有允许
    &LT /目录>
    &ltDirectory /家庭/ * /的public_html>
        选择指数多视图了FollowSymLinks
        所有的AllowOverride
        为了允许,拒绝
        所有允许
    &LT /目录>    ScriptAlias​​指令/的cgi-bin / / usr / lib目录/ cgi-bin目录/
    &ltDirectory/ usr / lib目录/ cgi-bin目录>
        设置AllowOverride无
        选项​​+ ExecCGI -MultiViews + SymLinksIfOwnerMatch
        为了允许,拒绝
        所有允许
    &LT /目录>    错误日志$ {} APACHE_LOG_DIR /error.log    #可能的值包括:调试,信息,通知,警告,错误,暴击,
    #警报,EMERG。
    LOGLEVEL警告    的CustomLog $ {} APACHE_LOG_DIR结合/access.log    别名/ DOC /的/ usr /共享/ DOC /
    &ltDirectory的/ usr /共享/ DOC />
        选择多视图索引了FollowSymLinks
        设置AllowOverride无
        为了否认,允许
        所有拒绝
        从127.0.0.0/255.0.0.0允许:: 1/128
    &LT /目录>&LT /虚拟主机>


解决方案

原来,问题是我的站点启用文件。显然,用户目录没有正确配置为允许mod_rewrite的工作。 /复制虚拟主机设置在/ var / WWW与小修改解决了问题。

 &ltDirectory /家庭/ * /的public_html>
    选择了FollowSymLinks索引
    所有的AllowOverride
    为了允许,拒绝
    所有允许
&LT /目录>

I'm trying to get a local copy of a website running that someone else put together. The site is deployed and functional and I'm trying to get a development version set up under my public_html directory.

The site uses mod_rewrite to redirect all traffic through a gateway script that performs various initialization steps. I have a strange problem where links including the .php extention work, but those without die with the following exception:

Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0 Fatal error: Unknown: Failed opening required 'redirect:/~george/site/.fiona/core/gateway.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0

Here is a copy of the .htaccess file (edited for my local installation)

RewriteEngine On
Options +FollowSymLinks

RewriteBase /~george/site/
RewriteCond %{REQUEST_URI} !.fiona/core/gateway.php
RewriteRule ^\.fiona/([a-z]+)/([a-zA-Z0-9_\-]+)(\.php)?$ .fiona/core/gateway.php?group=$1&destination=$2\.php [L,QSA]
RewriteCond %{REQUEST_URI} !.fiona/core/gateway.php
RewriteRule ^([a-z]+)/([a-zA-Z0-9_\-]+)(\.php)?$ .fiona/core/gateway.php?group=$1&destination=$2\.php [L,QSA]
RewriteCond %{REQUEST_URI} !.fiona/core/gateway.php
RewriteRule ^([a-zA-Z0-9_\-]+)(\.php)?$ .fiona/core/gateway.php?destination=$1\.php [L,QSA]

Here is what I see in my mod_rewrite logs

localhost/~george/site/login

127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#211168d0/subreq] (3) [perdir /home/george/public_html/site/] strip per-dir prefix: /home/george/public_html/site/login.php -> login.php
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#211168d0/subreq] (3) [perdir /home/george/public_html/site/] applying pattern '^\.fiona/([a-z]+)/([a-zA-Z0-9_\-]+)(\.php)?$' to uri 'login.php'
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#211168d0/subreq] (3) [perdir /home/george/public_html/site/] strip per-dir prefix: /home/george/public_html/site/login.php -> login.php
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#211168d0/subreq] (3) [perdir /home/george/public_html/site/] applying pattern '^([a-z]+)/([a-zA-Z0-9_\-]+)(\.php)?$' to uri 'login.php'
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#211168d0/subreq] (3) [perdir /home/george/public_html/site/] strip per-dir prefix: /home/george/public_html/site/login.php -> login.php
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#211168d0/subreq] (3) [perdir /home/george/public_html/site/] applying pattern '^([a-zA-Z0-9_\-]+)(\.php)?$' to uri 'login.php'
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#211168d0/subreq] (4) [perdir /home/george/public_html/site/] RewriteCond: input='/~george/site/login.php' pattern='!.fiona/core/gateway.php' => matched
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#211168d0/subreq] (2) [perdir /home/george/public_html/site/] rewrite 'login.php' -> '.fiona/core/gateway.php?destination=login.php'
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#211168d0/subreq] (3) split uri=.fiona/core/gateway.php?destination=login.php -> uri=.fiona/core/gateway.php, args=destination=login.php
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#211168d0/subreq] (3) [perdir /home/george/public_html/site/] add per-dir prefix: .fiona/core/gateway.php -> /home/george/public_html/site/.fiona/core/gateway.php
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#211168d0/subreq] (2) [perdir /home/george/public_html/site/] trying to replace prefix /home/george/public_html/site/ with /~george/site/
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#211168d0/subreq] (5) strip matching prefix: /home/george/public_html/site/.fiona/core/gateway.php -> .fiona/core/gateway.php
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#211168d0/subreq] (4) add subst prefix: .fiona/core/gateway.php -> /~george/site/.fiona/core/gateway.php
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#211168d0/subreq] (1) [perdir /home/george/public_html/site/] internal redirect with /~george/site/.fiona/core/gateway.php [INTERNAL REDIRECT]
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#21103668/initial] (3) [perdir /home/george/public_html/site/] applying pattern '^\.fiona/([a-z]+)/([a-zA-Z0-9_\-]+)(\.php)?$' to uri 'redirect:/~george/site/.fiona/core/gateway.php'
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#21103668/initial] (3) [perdir /home/george/public_html/site/] applying pattern '^([a-z]+)/([a-zA-Z0-9_\-]+)(\.php)?$' to uri 'redirect:/~george/site/.fiona/core/gateway.php'
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#21103668/initial] (3) [perdir /home/george/public_html/site/] applying pattern '^([a-zA-Z0-9_\-]+)(\.php)?$' to uri 'redirect:/~george/site/.fiona/core/gateway.php'
127.0.0.1 - - [05/Oct/2011:08:47:37 --0400] [localhost/sid#20f41ce8][rid#21103668/initial] (1) [perdir /home/george/public_html/site/] pass through redirect:/~george/site/.fiona/core/gateway.php

localhost/~george/site/login.php

127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224bf668/initial] (3) [perdir /home/george/public_html/site/] strip per-dir prefix: /home/george/public_html/site/login.php -> login.php
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224bf668/initial] (3) [perdir /home/george/public_html/site/] applying pattern '^\.fiona/([a-z]+)/([a-zA-Z0-9_\-]+)(\.php)?$' to uri 'login.php'
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224bf668/initial] (3) [perdir /home/george/public_html/site/] strip per-dir prefix: /home/george/public_html/site/login.php -> login.php
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224bf668/initial] (3) [perdir /home/george/public_html/site/] applying pattern '^([a-z]+)/([a-zA-Z0-9_\-]+)(\.php)?$' to uri 'login.php'
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224bf668/initial] (3) [perdir /home/george/public_html/site/] strip per-dir prefix: /home/george/public_html/site/login.php -> login.php
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224bf668/initial] (3) [perdir /home/george/public_html/site/] applying pattern '^([a-zA-Z0-9_\-]+)(\.php)?$' to uri 'login.php'
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224bf668/initial] (4) [perdir /home/george/public_html/site/] RewriteCond: input='/~george/site/login.php' pattern='!.fiona/core/gateway.php' => matched
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224bf668/initial] (2) [perdir /home/george/public_html/site/] rewrite 'login.php' -> '.fiona/core/gateway.php?destination=login.php'
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224bf668/initial] (3) split uri=.fiona/core/gateway.php?destination=login.php -> uri=.fiona/core/gateway.php, args=destination=login.php
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224bf668/initial] (3) [perdir /home/george/public_html/site/] add per-dir prefix: .fiona/core/gateway.php -> /home/george/public_html/site/.fiona/core/gateway.php
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224bf668/initial] (2) [perdir /home/george/public_html/site/] trying to replace prefix /home/george/public_html/site/ with /~george/site/
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224bf668/initial] (5) strip matching prefix: /home/george/public_html/site/.fiona/core/gateway.php -> .fiona/core/gateway.php
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224bf668/initial] (4) add subst prefix: .fiona/core/gateway.php -> /~george/site/.fiona/core/gateway.php
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224bf668/initial] (1) [perdir /home/george/public_html/site/] internal redirect with /~george/site/.fiona/core/gateway.php [INTERNAL REDIRECT]
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224c97b8/initial/redir#1] (3) [perdir /home/george/public_html/site/] strip per-dir prefix: /home/george/public_html/site/.fiona/core/gateway.php -> .fiona/core/gateway.php
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224c97b8/initial/redir#1] (3) [perdir /home/george/public_html/site/] applying pattern '^\.fiona/([a-z]+)/([a-zA-Z0-9_\-]+)(\.php)?$' to uri '.fiona/core/gateway.php'
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224c97b8/initial/redir#1] (4) [perdir /home/george/public_html/site/] RewriteCond: input='/~george/site/.fiona/core/gateway.php' pattern='!.fiona/core/gateway.php' => not-matched
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224c97b8/initial/redir#1] (3) [perdir /home/george/public_html/site/] strip per-dir prefix: /home/george/public_html/site/.fiona/core/gateway.php -> .fiona/core/gateway.php
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224c97b8/initial/redir#1] (3) [perdir /home/george/public_html/site/] applying pattern '^([a-z]+)/([a-zA-Z0-9_\-]+)(\.php)?$' to uri '.fiona/core/gateway.php'
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224c97b8/initial/redir#1] (3) [perdir /home/george/public_html/site/] strip per-dir prefix: /home/george/public_html/site/.fiona/core/gateway.php -> .fiona/core/gateway.php
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224c97b8/initial/redir#1] (3) [perdir /home/george/public_html/site/] applying pattern '^([a-zA-Z0-9_\-]+)(\.php)?$' to uri '.fiona/core/gateway.php'
127.0.0.1 - - [05/Oct/2011:08:58:18 --0400] [localhost/sid#222fdce8][rid#224c97b8/initial/redir#1] (1) [perdir /home/george/public_html/site/] pass through /home/george/public_html/site/.fiona/core/gateway.php

The links without the .php extension seem to make the initial redirect successfully, however, for some reason they appear to be unable to reroute to the absolute path.

I am by no means an expert on mod_rewrite, so there could very well be other issues here. Any ideas would be great.

EDIT Based on Marius' answer, I believe I've narrowed this down to an issue with mod_userdir in combination with mod_rewrite. Moving the site to /var/www resolves the problem. I would still like to get this working in my public_html directory.

EDIT Marius lead me closer to the solution in sites enabled. It turns out the problem was that MultiViews (allows apache to interpret index as index.php) was not enabled for user directories. Adding the following to my default sites enabled (/etc/apache2/sites-enabled/000-default) resolved the issue with .php extensions, but disables mod_rewrite.

<Directory /home/*/public_html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory> 

My entire sites enabled follows

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
    <Directory /home/*/public_html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

解决方案

It turns out the issue was with my sites enabled file. Apparently user directories were not configured properly to allow mod_rewrite to work. Copying the VirtualHost settings for /var/www/ with minor edits resolved the issue.

<Directory /home/*/public_html>
    Options Indexes FollowSymLinks
    AllowOverride all
    Order allow,deny
    allow from all
</Directory>

这篇关于与mod_rewrite的和mod_userdir问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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