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.

Rewrite wrong request

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

  1. #1
    Hi everybody,

    In my web site I have several index pages in different languages in the following format

    http://www.mysite.com/lang_index.html

    Two days ago I noticed increased, many times. Google bot activity on my site and when I checked my log file I found that all pages crawled were wrong web addresses: to the above index were added existing files from my site like

    /folder1/folder2/file.html

    So, the strings looked like

    http://www.mysite.com/lang_index.html/folder1/folder2/file.html

    And surprisingly all they returned code "200".

    My question is: is there any way to rewrite such requests to the first ".html" found in the string.

    Your help is greatly appreciated.
     
    georgi, Nov 13, 2013 IP
  2. MBDungo

    MBDungo Active Member

    Messages:
    163
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    58
    #2
    If you want to rewrite "/$var.html" into "/$var.html/folder1/folder2/file.html" then try using the mod_rewrite of Apache HTTP Server, and try to use these configuration directives in your .htaccess file:
    #once per htaccess
    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^([^/]+).html$ http://www.mysite.com/$1.html/folder1/folder2/file.html [L]
    Code (markup):
     
    MBDungo, Nov 13, 2013 IP
  3. georgi

    georgi Active Member

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #3
    I have already found the solution

    RewriteRule (.*\.html).*\.html$ $1 [R=301,L]

    thanks for you time.
     
    georgi, Nov 13, 2013 IP