0

我目前正在将 Apache2 PHP5 生产实例迁移到本地环境。

在 .htaccess 文件中,我发现了以下重写规则:

RewriteRule ^profile/?$ profile.php

这是工作。但是,当尝试访问 localhost/profile 时,我看到的是一个空页面,并且这个添加到了响应标头中

Content-Location:profile.class.php

如果我将规则更改为 ^profile/?$ 以外的任何内容,请说 ^profil/?$ 一切正常。

什么会导致这种奇怪的行为、命名冲突、保留字?

这是来自 mod_rewrite 的日志

% tail -f rewrite.log                          
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9c00a0/subreq] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.php -> profile.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9c00a0/subreq] (3) [perdir /var/www/] applying pattern '^sign-up/?([a-f0-9]+)?/?([a-f0-9]+)?/?$' to uri 'profile.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9c00a0/subreq] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.php -> profile.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9c00a0/subreq] (3) [perdir /var/www/] applying pattern '^sign-out/?$' to uri 'profile.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9c00a0/subreq] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.php -> profile.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9c00a0/subreq] (3) [perdir /var/www/] applying pattern '^new-app/?(budget)?/?([A-Za-z0-9-]+)?/?$' to uri 'profile.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9c00a0/subreq] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.php -> profile.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9c00a0/subreq] (3) [perdir /var/www/] applying pattern '^profile/([a-f0-9]{50})/?([a-f0-9]{50})?/?' to uri 'profile.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9c00a0/subreq] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.php -> profile.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9c00a0/subreq] (3) [perdir /var/www/] applying pattern '^profile/?([a-z0-9-]+)?/?$' to uri 'profile.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9c00a0/subreq] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.php -> profile.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.class.php -> profile.class.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] applying pattern '^sign-in/?$' to uri 'profile.class.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.class.php -> profile.class.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] applying pattern '^features/?$' to uri 'profile.class.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.class.php -> profile.class.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] applying pattern '^features/([a-z0-9-]+)/?$' to uri 'profile.class.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.class.php -> profile.class.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] applying pattern '^terms/?$' to uri 'profile.class.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.class.php -> profile.class.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] applying pattern '^(all|books|business|education|entertainment|finance|games|healthcare-and-fitness|lifestyle|medical|music|navigation|news|photography|productivity|reference|social-networking|sports|travel|utilities|weather)/?$' to uri 'profile.class.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.class.php -> profile.class.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] applying pattern '^(books|business|education|entertainment|finance|games|healthcare-and-fitness|lifestyle|medical|music|navigation|news|photography|productivity|reference|social-networking|sports|travel|utilities|weather)/([A-Za-z0-9-]+)/?$' to uri 'profile.class.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.class.php -> profile.class.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] applying pattern '^(books|business|education|entertainment|finance|games|healthcare-and-fitness|lifestyle|medical|music|navigation|news|photography|productivity|reference|social-networking|sports|travel|utilities|weather)/([A-Za-z0-9-]+)/invite/?([a-z0-9-]+)?/?$' to uri 'profile.class.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.class.php -> profile.class.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] applying pattern '^(books|business|education|entertainment|finance|games|healthcare-and-fitness|lifestyle|medical|music|navigation|news|photography|productivity|reference|social-networking|sports|travel|utilities|weather)/([A-Za-z0-9-]+)/(app-details|testers|test-reports|test-report|start|update|contact-tester)/?(\d+)?/?([a-z0-9-]+)?/?$' to uri 'profile.class.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.class.php -> profile.class.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] applying pattern '^forgot-password/?$' to uri 'profile.class.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.class.php -> profile.class.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] applying pattern '^connect-with-facebook/?$' to uri 'profile.class.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.class.php -> profile.class.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] applying pattern '^account/?(confirm-email|reset-password|send-confirmation-link)/?([A-Za-z0-9]+)?/?([_\.0-9a-zA-Z-%+]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+([a-zA-Z]{2,4}$))?$' to uri 'profile.class.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.class.php -> profile.class.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] applying pattern '^public-scripts/?(add-device|propose-projects|generate-mass-payment|edit-device|your-devices|get-app-password|remove-device|beta-test-request|change-project-tester-status|download-udids|download-app|open-report|rate-report|reply|invite-search|invite-user|ignore-invite|uninvite|add-device-over-air|save-device-over-air|send-air-link|search-android-device)/?([A-Za-z0-9]+)?/?([A-Za-z0-9\.]+)?/?$' to uri 'profile.class.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.class.php -> profile.class.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] applying pattern '^rss/?$' to uri 'profile.class.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/profile.class.php -> profile.class.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (3) [perdir /var/www/] applying pattern '^feed/?$' to uri 'profile.class.php'
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9d20a0/initial] (1) [perdir /var/www/] pass through /var/www/profile.class.php
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9cd0a0/initial] (1) [perdir /var/www/] pass through /var/www/favicon.ico
192.168.0.31 - - [30/Oct/2012:16:18:31 +0100] [192.168.0.40/sid#7f930db80978][rid#7f930d9c12c0/initial/redir#1] (3) [perdir /var/www/] strip per-dir prefix: /var/www/404.php -> 404.php

.htaccess

RewriteEngine on

RewriteRule ^sign-up/?([a-f0-9]+)?/?([a-f0-9]+)?/?$ sign-up.php?project_token=$1&invite_token=$2
RewriteRule ^sign-out/?$ sign-out.php
RewriteRule ^new-app/?(budget)?/?([A-Za-z0-9-]+)?/?$ new-app.php?stage=$1&app=$2
RewriteRule ^profile/([a-f0-9]{50})/?([a-f0-9]{50})?/? profile-other.php?token=$1&project=$2
RewriteRule ^profile/?([a-z0-9-]+)?/?$ profile.php?profile_menu_cat=$1
RewriteRule ^admin/?([a-z0-9-]+)?/?$ admin.php?profile_menu_cat=$1
RewriteRule ^faq/?(our-application|for-beta-testers|for-developers)?/?$ faq.php?app_cat=$1
RewriteRule ^get/?([A-Za-z0-9-]+)/?([a-z0-9]+)\.?(ipa|plist|apk)?/?$ download.php?url=$1&token=$2&$3
RewriteRule ^contact/?$ contact.php
RewriteRule ^sign-in/?$ sign-in.php
RewriteRule ^features/?$ features.php
RewriteRule ^features/([a-z0-9-]+)/?$ features.php?sub=$1
RewriteRule ^terms/?$ terms.php
RewriteRule ^(all|books|business|education|entertainment|finance|games|healthcare-and-fitness|lifestyle|medical|music|navigation|news|photography|productivity|reference|social-networking|sports|travel|utilities|weather)/?$ browse.php?category=$1

RewriteRule ^(books|business|education|entertainment|finance|games|healthcare-and-fitness|lifestyle|medical|music|navigation|news|photography|productivity|reference|social-networking|sports|travel|utilities|weather)/([A-Za-z0-9-]+)/?$ app.php?category=$1&app=$2&app_cat=$3&extra=$4

RewriteRule ^(books|business|education|entertainment|finance|games|healthcare-and-fitness|lifestyle|medical|music|navigation|news|photography|productivity|reference|social-networking|sports|travel|utilities|weather)/([A-Za-z0-9-]+)/invite/?([a-z0-9-]+)?/?$ invite.php?category=$1&app=$2&app_cat=invite&extra=$4

RewriteRule ^(books|business|education|entertainment|finance|games|healthcare-and-fitness|lifestyle|medical|music|navigation|news|photography|productivity|reference|social-networking|sports|travel|utilities|weather)/([A-Za-z0-9-]+)/(app-details|testers|test-reports|test-report|start|update|contact-tester)/?(\d+)?/?([a-z0-9-]+)?/?$ app.php?category=$1&app=$2&app_cat=$3&extra=$5&version=$4

RewriteRule ^forgot-password/?$ forgot-password.php
RewriteRule ^connect-with-facebook/?$ connect-with-facebook.php
RewriteRule ^account/?(confirm-email|reset-password|send-confirmation-link)/?([A-Za-z0-9]+)?/?([_\.0-9a-zA-Z-%+]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+([a-zA-Z]{2,4}$))?$ account.php?1=$1&2=$2&3=$3
RewriteRule ^public-scripts/?(add-device|propose-projects|generate-mass-payment|edit-device|your-devices|get-app-password|remove-device|beta-test-request|change-project-tester-status|download-udids|download-app|open-report|rate-report|reply|invite-search|invite-user|ignore-invite|uninvite|add-device-over-air|save-device-over-air|send-air-link|search-android-device)/?([A-Za-z0-9]+)?/?([A-Za-z0-9\.]+)?/?$ public-scripts.php?1=$1&2=$2&3=$3
RewriteRule ^rss/?$ rss.php
RewriteRule ^feed/?$ rss.php

ErrorDocument 404 /404.php
4

1 回答 1

2

这听起来像 mod_negotiation 在不需要的时候做它的事情。该模块将尝试将请求 URI 的文件映射匹配到与请求文件“接近”的多个不同文件。您可以通过关闭该Multiviews选项来关闭它。从您看到该语句的 vhost/server 配置中将其删除Options,或者您可以尝试在您的 htaccess 中否定它:

Options -Multiviews
于 2012-10-30T17:59:37.350 回答