homepage Welcome to WebmasterWorld Guest from 54.166.122.65
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
"AddType x-mapp-php5 .php" in .htaccess causes Apache to serve bad URL
georgi58



 
Msg#: 4623471 posted 9:07 am on Nov 15, 2013 (gmt 0)

Hi everybody,

My website is on 1and1 shared hosting and to enable PHP I needed to put in my .htaccess the following

AddType x-mapp-php5 .php .html .htm .shtml

Two days ago I noticed increased Google bot activity on my website and checked my log file. The bot crawled thousands of bad URL-s and surprisingly they all returned code "200".

For example

http://www.mywebsite.com/index.html/folder1/folder2/index1.html

If I put slash after any URL from my site it displays the same web page but all links are wrong.

I played a lot with my .htaccess and finally found out that the problem is caused by

AddType x-mapp-php5 .php .html .htm .shtml

If I remove that line all is fine - 404 for all wrong URL-s. But PHP not working.

Any help is greatly appreciated

 

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4623471 posted 10:23 am on Nov 15, 2013 (gmt 0)

I don't understand. Does your site have .html files that need to be parsed as .php? AND .htm? AND .shtml?

topr8

WebmasterWorld Senior Member topr8 us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4623471 posted 10:49 am on Nov 15, 2013 (gmt 0)

by "bad url's"
do you mean url's that do not exist?

what do you see if you enter

www.example.com/index.html/folder1/folder2/index1.html

into your address bar?

penders

WebmasterWorld Senior Member penders us a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



 
Msg#: 4623471 posted 10:49 am on Nov 15, 2013 (gmt 0)

From the 1and1 help center page for "Manually Set the Version of PHP Using an .htaccess File [help.1and1.com]", the examples use AddHandler, not AddType ...?

AddHandler x-mapp-php5 .php



If I put slash after any URL from my site it displays the same web page but all links are wrong.


This has nothing to do with Apache/PHP handlers. This is because you are using relative URLs in your page, and is to do with how the browser resolves these URLs. (You might be able to set a BASE element on the page to resolve this, without having to update all your links.)

georgi58



 
Msg#: 4623471 posted 12:33 pm on Nov 15, 2013 (gmt 0)

My site has html files from which I am serving Google adds using "php include" and the only way to have is by adding
AddType x-mapp-php5
in .htaccess.
AddType x-mapp-php5 is from 1and1 support and I also tried
AddHandler x-mapp-php5 .php, but nothing changes.

by "bad url's" I mean url-s that do not exist
when I enter
www.example.com/index.html/folder1/folder2/index1.html
I see
www.example.com/folder1/folder2/index1.html page but no images.

"/" after any normal url like
www.example.com/index.html/
has nothing to do with my browser - if I put slash at the end of this post url I get 404

penders

WebmasterWorld Senior Member penders us a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



 
Msg#: 4623471 posted 1:43 pm on Nov 15, 2013 (gmt 0)

"/" after any normal url like
www.example.com/index.html/
has nothing to do with my browser


Unless you have additional server-side processing to trap this (which is probably what WebmasterWorld does) or you are manipulating your URLs in some way (semi-pretty, MVC-like, ...) then this has everything to with the browser.

Without any additional server-side processing, a request for "example.com/index.html/hello" will normally result in the server returning "example.com/index.html" (where "index.html" is a valid page and "hello" does not exist). However, the browser thinks you are at "example.com/index.html/hello".

Any relative path in the client-side page (anchors, stylsheets, scripts, ...) is now relative to "example.com/index.html/hello", not "example.com/index.html". So, if you had a relative link to "folder/page2.html", the browser is now going to request "example.com/index.html/folder/page2.html", not "example.com/folder/page2.html". As mentioned above, "example.com/index.html/folder/page2.html" is going to "successfully" (200 OK) return "example.com/index.html" (again!), but the browser now thinks you are at "example.com/index.html/folder/page2.html", etc. etc...

when I enter
www.example.com/index.html/folder1/folder2/index1.html
I see
www.example.com/folder1/folder2/index1.html page but no images.


...so you do already have some URL redirection?

georgi58



 
Msg#: 4623471 posted 1:54 pm on Nov 15, 2013 (gmt 0)

yes, I have many re-directions
but how Google gets all those abnormal compilations from my website? many thousands!

georgi58



 
Msg#: 4623471 posted 1:59 pm on Nov 15, 2013 (gmt 0)

And I also tried your suggestion
example.com/index.html/hello
with my friends websites and got 404 for all such requests

georgi58



 
Msg#: 4623471 posted 2:08 pm on Nov 15, 2013 (gmt 0)

And final testing point: if I remove from my .htaccess ONLY the line

AddType x-mapp-php5 .php .html .htm .shtml

all is back to normal i.e. I get 404 for all variations mentioned above including slash behind. For all! with the same browser.

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4623471 posted 9:00 pm on Nov 15, 2013 (gmt 0)

The issue is with Path Info, which by default is handled differently in html than in php.

:: detour to look up, because I get it backward every time ::

"Off" = if there is more stuff after the end of the URL, the request gets a 404
"On" = extra stuff after the end of the URL shows up in browser's address bar but doesn't affect request
"Default" =
The core handler for normal files defaults to rejecting PATH_INFO requests. Handlers that serve scripts, such as cgi-script and isapi-handler, generally accept PATH_INFO by default.


See what happens if you add the line
AcceptPathInfo Off
This is a core directive. It can go anywhere, but it's best to put it near the top of your htaccess so you remember where it is.

georgi58



 
Msg#: 4623471 posted 8:28 am on Nov 16, 2013 (gmt 0)

AcceptPathInfo Off


No changes

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved