1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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

Discussion in 'Apache' started by georgi, Nov 15, 2013.

  1. #1
    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
    Code (markup):
    A few 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
    Code (markup):
    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
    Code (markup):
    If I remove that line all is fine - 404 for all wrong URL-s. But PHP not working.

    Any help is greatly appreciated
     
    georgi, Nov 15, 2013 IP
  2. makeit easy

    makeit easy Active Member

    Messages:
    2,067
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    Try this:

    find "index.php" file replace its name with "index.html"
    find "directoryindex index.php" in your htaccess replace it with "directoryindex index.html"
    if you can't find "directoryindex index.php" in your htaccess, don't worry, just add directoryindex index.html
    of course make sure if your htaccess has "options followsymlinks" and "rewriteengine on" lines.

    If all these above not working you can try adding "directorybase /" to .htaccess. Some hosts need it to redirect properly. You might end up with a highly damaged database. Take a full backup of your site before playing with those configs.

    If it's a wordpress site or another cms, solution may be different. You may need to change some configs with your URL structure in the admin panel. It is complicated, not easy. You may end up with a highly damaged database.

    Don't forget to take a full backup of your site before trying something new.
     
    Last edited: Nov 17, 2013
    makeit easy, Nov 17, 2013 IP
  3. georgi

    georgi Active Member

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #3
    not working
     
    georgi, Nov 18, 2013 IP
  4. makeit easy

    makeit easy Active Member

    Messages:
    2,067
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #4
    Maybe your site script is old and not working on the new php version. PHP 5.3x may not run all of the old scripts that were written for older PHP versions.
    It's hard to guess what the issue is with the limited info about your site.
     
    makeit easy, Nov 18, 2013 IP
  5. georgi

    georgi Active Member

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #5
    i use
    <?php include(''); ?>
    and it works with all versions of PHP since 2007 up to 5.4
     
    georgi, Nov 19, 2013 IP
  6. makeit easy

    makeit easy Active Member

    Messages:
    2,067
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #6

    Yes php include should work. But I think we need more info to understand what the issue is. For example, is it wordpress? If not, what kind of php script running? What is your current .htaccess file? What is the error message when php not working? Do you see http 500 and 400 errors?
     
    makeit easy, Nov 19, 2013 IP
  7. georgi

    georgi Active Member

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #7
    ok. here it is:
    i use <?php include(''); ?> to call AdSense code as well as some footers in my html pages. It is not wordpress and there are no other scripts. To use pnp include I need PHP enabled on the server. This is done, on 1and1 shared hosting, by adding the line
    AddHandler x-mapp-php6 .php .html .htm
    previously
    AddType x-mapp-php5 .php .html .htm
    both lines do the same.

    The problem is Apache, that serves bad url-s, which are indexed by SE. One example for such url is

    www.example.com/index.html/
    Notice the slash at the end. Normally such url should return 404.
    Without the line
    AddHandler x-mapp-php6 .php .html .htm
    in .htaccess server respond properly i.e. returns 404 for the above url.
    But that line is the only way to have PHP enabled and use <?php include(''); ?>

    Is there any way to keep php and have Apache work properly?
    Thanks for your time.
     
    georgi, Nov 20, 2013 IP
  8. makeit easy

    makeit easy Active Member

    Messages:
    2,067
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #8
    Yes there should be a way.

    So, it's a plain html site? Then the issue is easier to resolve since I have to agree on
    I think something might be wrong with the current htaccess. You can PM me if you don't want to post your current htaccess file here. I can take a look at it when I have time. Your site URL can also help much to diagnose the issue.


    There must be a redirect to do it since .html extension doesn't end with a slash. Most probably the htaccess has multiple redirects and some of those make the apache instable.
    .htaccess is almost the most powerful element of a server. You can even damage hardware with a wrong htacess.
     
    makeit easy, Nov 20, 2013 IP
  9. georgi

    georgi Active Member

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #9
    There must be a redirect to do it since .html extension doesn't end with a slash. Most probably the htaccess has multiple redirects and some of those make the apache instable.
    Code (markup):
    I mean you put the slash yourself, artificially, to test the apache response.
    And I have already stripped all lines from .htaccess - nothing changes. if you have in there

    Options +FollowSymLinks
    AddHandler x-mapp-php6 .php .html .htm
    Code (markup):
    just this, then wrong behavior. When you remove the line - ok.

    that is it!
     
    georgi, Nov 21, 2013 IP
  10. makeit easy

    makeit easy Active Member

    Messages:
    2,067
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #10
    Is this site root or add-on domain of your hosting account? Is it a cpanel hosting?
     
    makeit easy, Nov 21, 2013 IP
  11. georgi

    georgi Active Member

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #11
    it is root site and not cpanel.
    it is something to do with shared hosting server configuration, but support does not want to help. On my machine, my localhost, all works fine. and i also had the opportunity, recently, to test it on another company's shared hosting server - the same mistakes.

    So, let's stop here. I really appreciate your willingness to help me.

    god bless
     
    georgi, Nov 22, 2013 IP
  12. makeit easy

    makeit easy Active Member

    Messages:
    2,067
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #12
    I think there would be a probability if it wasn't a root/main domain of your hosting account.
    I would seek for a help from the hosting support. Also I would try to run the site on another hosting to make sure if the issue is really hosting related.
    Good luck.
     
    makeit easy, Nov 22, 2013 IP