prinsen
prinsen

Reputation: 778

.htaccess strange behavior

I'm currently migrating a Apache2 PHP5 production instance to a local environment.

In the .htaccess file I found the following rewrite-rule:

RewriteRule ^profile/?$ profile.php

which is working. However, when trying to access localhost/profile I'm presented with an empty page and this addition to the response header

Content-Location:profile.class.php

If I change the rule to anything other than ^profile/?$, say ^profil/?$ everything works.

What can cause this strange behavior, naming collisions, reserved words?

Here is the log from 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

Upvotes: 0

Views: 157

Answers (1)

Jon Lin
Jon Lin

Reputation: 143946

This sounds like mod_negotiation doing its thing when it's unwanted. That module will try to match a request URI's file mapping to multiple different files that are "close" to the requested file. You can turn it off by turning off the Multiviews option. Either remove it from the vhost/server config where you see the Options statement, or you can try negating it in your htaccess:

Options -Multiviews

Upvotes: 2

Related Questions