andrewlocatelliwoodcock

Thoughts on Software

WordPress permalinks not working: some tips on resolving

with 13 comments


Well I was bashing my head off this one for a while! In the hopes of saving others some heartache, I’m going to put my problem and the resolution up here …

The basic issue was that I had inherited a very nice WordPress-based site and needed to set it up locally in order to debug some issues. I brought the website locally to my dev box via FTP, setup XAMPP, brought down and restored the database (tip: remember to change the siteurl and home values in wp_options to the local URL of your website … ) and modified the Apache’s httpd.conf file to recognize the file path where I had setup my local website. So far, so good. I ran the website and saw the lovely home page but as soon as I clicked any link on the page, I was booted back to the local XAMPP homepage.

After a lot (and I mean a lot) of head-scratching, I realized that the issue had to be that redirects were failing: my pretty permalinks of the format http://localhost/category/%5Bwhatever%5D were not being correctly redirected by Apache.

The issue lay in the WordPress site’s .htaccess file. This file should reside in the root of a WordPress site that is using pretty permalinks and handles mapping pretty permalinks to the real, underlying URL. I had downloaded the .htaccess file when I took a local copy of the WordPress site so my .htaccess file was identical to the one on the live site but my structure locally was different to that of the live site. Locally, my WordPress site was not at the document root whereas it was on the live server … this meant that my copied .htaccess file read something like:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
It was the final RewriteRule that was causing the problem: it was redirecting everything to the ROOT/index.php file which existed but happened to be the index.php file for XAMPP! I had forgotten (or rather, not realized) that I needed to redirect to the index.php file of my WordPress site:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /[wordpresssite]/index.php [L]
</IfModule>
# END WordPress

D’oh!

Hopefully this post might save someone else (or even myself in future!) a lot of time debugging seemingly weird behaviour.

 

 

Written by andrewlocatelliwoodcock

December 22, 2011 at 18:42

Posted in Apache, Permalink, Wordpress

Tagged with , ,

13 Responses

Subscribe to comments with RSS.

  1. I am really enjoying the theme/design of your blog. Do you ever run into any internet browser compatibility problems? A handful of my blog visitors have complained about my blog not operating correctly in Explorer but looks great in Chrome. Do you have any advice to help fix this problem?

    Merilyn Leight

    December 29, 2011 at 14:09

  2. Hi would you mind sharing which blog platform you’re working with? I’m looking to start my own blog soon but I’m having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most blogs and I’m looking for something unique. P.S Apologies for getting off-topic but I had to ask!

    Maile Firpo

    January 1, 2012 at 19:14

  3. […] very frustrating hours trying to get things working. Pretty permalinks was one issue I encountered (see my earlier post) and once that was resolved I needed to get debugging working. Now, I admit that I am very much a […]

    • You’re on top of the game. Thanks for sharing.

      Mitchell

      January 9, 2012 at 12:40

  4. Great – I should definitely pronounce, impressed with your website. I had no trouble navigating through all tabs and related info ended up being truly easy to do to access. I recently found what I hoped for before you know it at all. Quite unusual. Is likely to appreciate it for those who add forums or something, site theme . a tones way for your client to communicate. Excellent task..

    Edmundo Tresselt

    January 6, 2012 at 04:40

  5. Wow! That’s a really neat answer!

    Tangie

    January 9, 2012 at 18:57

  6. Hi, i read your blog occasionally and i own a similar one and i was just wondering if you get a lot of spam feedback? If so how do you prevent it, any plugin or anything you can suggest? I get so much lately it’s driving me crazy so any help is very much appreciated.

    Trey Lipira

    January 10, 2012 at 00:19

  7. An intelligent answer – no BS – which makes a pleasant change

    Bobbi

    January 10, 2012 at 05:22

  8. This blog is definitely cool and factual. I have picked up helluva handy tips out of this amazing blog. I’d love to visit it over and over again. Cheers!

    colon c

    January 12, 2012 at 18:33

  9. Thanks for the article, it was interesting and compelling. I found my way here through Google, I will come back another time 🙂

    Vincent Carnero

    January 14, 2012 at 11:49

  10. Hi There

    I am scratching my hair for quite while now.

    I have added the .htaccess like yours, but I am facing a problem in the DB, all the time that I change siteurl and home on options table and refresh the site, it change back to what it was. 😦 weird stuff

    I am trying to move the site from UAT to WWW and not having much joy.

    Thanks

    Jean

    Jean

    January 8, 2013 at 01:16

  11. This is a really good tip especially to those fresh to the blogosphere.
    Simple but very precise info… Many thanks for sharing this one.
    A must read post!

    HayDay Cheats

    April 19, 2014 at 15:51


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: