Getting "mywebsite.org/" to solve the problem "mywebsite.org/index.php"

In my work we have various web pages that I think the boss is grading lower than they should be because "mywebsite.org/category/" looks like a different search engine url than "mywebsite.org /category/index.php "although they show the same file. I don't think it works like that, but he is convinced. Maybe I'm wrong. I have two questions:

  • How can I make it say "index.php" in the address bar of all subcategories?
  • Does pagerank really work?
+2


source to share


7 replies


  • Apart from changing all the links everywhere, an easier solution is to use a rewrite rule. Make sure this is a permanent redirect, or Google will keep using the old link (without index.php). How you do it depends exactly on your web server, but for Apache HTTPd it looks something like the following.
  • Yes. Or so I heard. Very few people know for sure. But Google refers to this guide (as "Be consistent"). Be sure to check out all Google Webmaster Guidelines .

Apache config for rewrite rule:



# in the generic config
LoadModule rewrite_module modules / mod_rewrite.so

# in your virutal host
RewriteEngine On

# redirect everything that ends in a slash to the same, but with index.php added
RewriteRule ^ (. *) / $ $ 1 / index.php [R = 301, L]

# or the other way around, as suggested
# RewriteRule ^ (. *) / Index.php $ $ 1 / [R = 301, L]
+3


source


Adding this code to the top of every page should also be done:



<?php
if (substr($_SERVER['REQUEST_URI'], -1) == '/') {
    $new_request_uri = $_SERVER['REQUEST_URI'].'index.php';
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: '.$new_request_uri);
    exit;
}
?>

      

+3


source


  • You don't tell us if you're using straight PHP or some other framework, but for PHP, you probably just need to change all links on your site to "mywebsite.org/category/index. PHP".

  • I think this may affect your search engine rankings. However, you are better off using only "mywebsite.org/category" rather than adding "index.php" to each one.

In the end, you need to make sure that all of your links on your site use one or the other. What is actually displayed in the address bar is irrelevant.

+1


source


A simple solution is to set the tag <head>

:

<link rel="canonical" href="http://mywebsite.org/category/" />

      

Then, no matter which page the search engine ends on, it will know that it is just a different kind /category/

And for your second question, yes, it can affect your results if Google thinks you are spam. If they didn't, they wouldn't have added support rel="canonical"

. Although I wouldn't be surprised if they treat the somedir/index.*

same way assomedir/

+1


source


I'm not sure if / category / and / category / index.php count as two URLs for seo, but chances are good that they will affect them in one way or another. There is nothing wrong with making a quick change to be sure.

A few thoughts:

Url

Instead of adding /index.php, you'd be better off making sure that none of them have index.php on them, since the "index" keyword is probably not what you want.

You can make a script that will check if the url of the current page ends in index.php and remove it and then forward to the resulting url.

For example, on one of my sites I need "www". for my domain (www.domain.com and domain.com counts as two URLs to search, though not always), so I have a script that checks every page, and if there is no www. it advertises it and forward.

    if (APPLICATION_LIVE) {
        if ( (strtolower($_SERVER["HTTP_HOST"]) != "www.domain.com") ) {
            header("HTTP/1.1 301 Moved Permanently"); // Recognized by search engines and may count the link toward the correct URL...
            header("Location: " . 'www.domain.com/'.$_SERVER["REQUEST_URI"] );
            exit();
        }
    }

      

You can use the mode to do what you want.

This way, if the crawler visits the wrong URL, they will be notified that it has been replaced with the correct URL. If a person visits the wrong url, they will be redirected to the correct url (most of them won't notice), and then if they copy the url from the browser to send someone or a link to that page, they end up will eventually link to the correct URL for that page.

LINKS URL

They are, like other pages linking to your pages, more important to SEO. Make sure that all your links on the site are using the correct URL (without / index.php), and if you have a link to this page function it does not include the /index.php part. You cannot control how everyone links to you, but you can control it, for example, with a script in item 1.

URL ROUTING

You might also consider using some sort of structure or standalone URL redirection scheme. This could make it so there were more keywords, etc.

See an example here: http://docs.kohanaphp.com/general/routing

+1


source


I agree with everyone who says to drop index.php. Please do not force your visitor to enter index.php, if they do not enter it, they can get the same result.

You didn't say if you are running IIS or Apache. IIS can be set to have index.php as the default page so that http://mywebsite.org/ will resolve correctly without specifying index.php.

I would say that if you want to enable the default page and force users to enter the page name in the URL, make the page name meaningful to the search engine and to your visitors.

Example:

http://mywebsite.org/teaching-web-scripting.php 

      

is much more descriptive and useful for SEO rankings than just

http://mywebsite.org/index.php

      

+1


source


Perhaps you want to look at robots.txt files? Not exactly the best solution, but you should be able to implement something workable with them ...

-1


source







All Articles