Slugging it out with SEO |
Written on Jan 02, 2016 by Steven |
I’m trying to start of the new year by updating all my web sites. I’ve been researching SEO (search engine optimization) for a few months, but only recently started to work through how to actually do it. The last few days have been a eureka moment for me. The first problem I had to deal with was how to hide the index script. Generally if you are using Apache you can do this with an In researching and viewing how WordPress does things, I ran across this great article. It walks through each line of WordPress’ With this missing piece of the puzzle now in place, I was able to actually to modify my The real magic then happened in the script itself. Using the REQUEST_URI was pretty easy, once I figured out a few bugs in the CMS. As an example, here is some simplistic router code. It isn’t the cleanest yet, but it works. # Get slug Note that the slug right now is just the article ID as that is how the existing code finds the article. It isn’t the most friendly, but it does work. In fact, I could leave it if I really wanted to. I haven’t decided yet how to actually define the slugs. WordPress, by default, uses a date with title system like this: I’ve seen other sites that leave the ID and add the title to end like so: And there you have it. I’ve now built about a dozen slug routes on my test site. Things seem to work pretty well, but I had to hack a lot of my internal code to ensure they print the slugs and not the query strings. For now, I’ve also set up my router to allow either format. In fact, for some internal facing routines I may not even bother. If WordPress doesn’t, why should I? |
The comments are owned by the poster. We aren't responsible for its content. |