I have a blog as part of my site. The address of the blog is ../blog.php. If you go to blog.php you will see the most recent blog entry and there will be links to other entries. The links to other entries will be the same PHP page but there is a query string which tells the page to show the content for another blog entry ie ../blog.php?entry=4 or ../blog.php?entry=27

Every blog entry has its own fixed address ie ../blog.php?entry=27 which can be linked to from outside the site and will always show the right blog entry but the URL ../blog.php will always show the most recent blog entry and so its content is often changing and is a duplicate of one of the content on for example ../blog.php?entry=43 which is the fixed address for that content.

The blog has been up for over a year now but although the rest of the site is ranking well in Google pretty much nothing on the blog has even been indexed so I'm pretty sure I must be doing something wrong SEO wise. What would be the best practice so that it doesn't matter that blog.php's content is always changing to something completely different and is a copy of the content on another URL? And does it matter that all the blog entries are using the same page, just different content from different query strings?

  • Are you running on windows or linux/unix?
    – Kuya
    Commented Sep 9, 2015 at 4:26

2 Answers 2


Yes, it matters a great deal. If your page is blog.php?entry=## how does the crawler know what even goes there? As far as the crawler is concerned, the page has no content.

To fix this issue requires several things to be done. (since you already have blog entries).

First - Create a new field in your blog entry table like PageName varchar(50) NOT NULL

Second - Populate that field for each of your entries with a title related that entry's content like "how-to-make-great-crepes". This will be used for two things. Note: Make sure every page title is unique!

  1. Your new pretty url
  2. As a parameter to tell blog.php what to display instead of using a number.

Third - Rewrite your sql select statement changing SELECT ... FROM ... WHERE id=something to SELECT ... FROM ... WHERE PageName=something. Now we are pulling content based on the page name instead of based on the unique id.

Fourth - Create a rewrite rule in your .htaccess file.

RewriteEngine On    # Turn on the rewriting engine
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule    ^([A-Za-z0-9_-]+)$    blog.php?entry=$1    [NC,L]    # Handle blog requests

Fifth - (because you have existing entries) Create a permanent redirect to your existing entries. This is also done in your .htaccess file.

Redirect 301 /blog.php?entry=1 /pretty-url-here
Redirect 301 /blog.php?entry=2 /pretty-url-here

Why do you need the redirects? Because other people may already be linking to your blog entries using the old link http://example-site.com/blog.php?entry=43. We need to redirect them to the new URL.

Finally, rewrite the links to your blog entries like this

<a href="/how-to-make-great-crepes">How to Make Great Crepes</a>

instead of

<a href="/blog.php?entry=43">How to Make Great Crepes</a>

I know this may seem like a lot of work, but it will be worth it in the long run for SEO purposes.

Hope this helps.

  • Wow! Thanks so much for not only the answer but complete instructions on how to go about fixing things. You've helped me out hugely. Thanks a lot. Commented Sep 12, 2015 at 6:31
  • One more quick thing if you don't mind. What about the blog.php page when it doesn't have a query string? This is linked to from the site's main navigation bar and currently shows the most recent entry. Obviously this is duplicate content of that blog entry's own page and means blog.php's content regularly completely changes. Would just having a no index meta tag stop problems here or do I need to do something more? Thanks again. Commented Sep 12, 2015 at 6:43
  • Your asking this for SEO or for the .htaccess file?
    – Kuya
    Commented Sep 12, 2015 at 6:46
  • I hadn't got as far as thinking about blog.php in the .htaccess file! I was thinking about the SEO. Commented Sep 12, 2015 at 7:31
  • For SEO there is no concern. Without a parameter, the crawler will see whatever is there.
    – Kuya
    Commented Sep 12, 2015 at 7:33

Yes, it does matter that all your blog entries are using the same page with different query strings for different content. Not every search engine spider crawls dynamic pages (URL contains a ? character) as well as static pages (URL with descriptive words).

For better SEO and especially to make it user-friendly, you must change your URL structure so that it contains relevant words rather than parameters and variables. (See page 8 on Google's Search Engine Optimization Starter Guide for more details on the best way to go about doing this.)

If your blog runs on Wordpress, you can easily do this by changing your Wordpress permalink structure. (How to change your WordPress Permalink Structure)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.