Mobile app version of vmapp.org
Login or Join
Berumen354

: SEO on pages whose content is determined by query string in URL 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

@Berumen354

Posted in: #QueryString #Seo #Url

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?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Berumen354

2 Comments

Sorted by latest first Latest Oldest Best

 

@Gail5422790

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!


Your new pretty url
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= [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
etc.


Why do you need the redirects? Because other people may already be linking to your blog entries using the old link 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.

10% popularity Vote Up Vote Down


 

@Connie744

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)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme