WordPress.org

Ready to get started?Download WordPress

Forums

How to redirect or block access to a folder that points to your subdomain ? (2 posts)

  1. nvblog
    Member
    Posted 7 years ago #

    Here is my config.

    My WP->Options->General Configurations are:

    WordPress address (URI):http://blog.wordpress.com/
    Blog address (URI): http://blog.wordpress.com/
    (Above site is taken as an example...)

    But.......
    Users can access the blog by going to
    http://www.wordpress.com/blog/index.php

    Why ?

    but going to
    http://www.wordpress.com/blog/
    http://www.wordpress.com/blog

    gives them 404 error, just what I wanted !!

    Can I have that done for
    http://www.wordpress.com/blog/index.php

    I shall grealty appreciate your help.

    If you would like to see here is the live site
    http://blog.nepalvista.com/
    http://www.nepalvista.com/blog/index.php (i want to get rid of this one!)

    Please help. I believe TWO DOORS to my blog is a duplicate content!!! I only need one door.

    I shall greatly appreciate your help.

  2. nvblog
    Member
    Posted 7 years ago #

    Alright, i figure this out but don't know if this is the correct way to do it. It does what I wanted for now. It blocks access to the folder that is used by the subdomain.

    Inserted this code at the top of index.php file.

    <?php
    $_SERVER[HTTP_HOST] = strtolower($_SERVER[HTTP_HOST]);
    if($_SERVER[HTTP_HOST]!== "blog.nepalvista.com") {
    ?>
    <html>
    <head>
    <title>Oops, that's the wrong address for this blog!</title>
    <meta name="robots" content="nofollow,noindex">
    </head>
    <div>
    <center>
    Then I gave some message here about the address of my blog but have not provided any links. Users will copy paste the address to their browser to view the site. If I have a link here, i fear search engines will follow... i don't know if that's good even with a rel="nofollow" tag.
    </center>
    </div>
    </body>
    </html>
    <?php
    exit();
    }
    ?>
    <?php
    /* Short and sweet */
    define('WP_USE_THEMES', true);
    require('./wp-blog-header.php');
    ?>

    This has solved my problem, but I don't know if this is the way to do correctly.

    I would love your suggestions and further help. Instead of showing messages to users, should i automatically redirect them to the the blog address (which is the subdomain address blog.nepalvista.com) Will automatic redirection hurt search engines ?

    Thank you in advance for any suggestions, etc.

    WordPress rocks! and i hope future developments makes wordpress blogs free from duplicate contents!!!

    thak you thank you thank and

    "I hope you will visit Nepal someday!"

Topic Closed

This topic has been closed to new replies.

About this Topic