X marks the spot

random commentary on life, the universe, and anything

July 23, 2015
by puhfu
0 comments

WordPress, permalinks, and 404 errors

One of the things that has been on my WordPress to-do list has been changing from Default (http://localhost/?/p=123) permalinks to more SEO-friendly ones (http://localhost/sexy-permalink) for a couple of academic websites that I support.

WordPress is normally so ridiculously simple to use, even self-hosted, but getting this change to work took a fair amount of Google spelunking.

The Rackspace CentOS 6 virtual server that I am running this particular site on uses apache VirtualHosts to map each WordPress site to a separate directory.

# site1.org
<VirtualHost 12.34.56.78:80>
     DocumentRoot /var/www/html/site1
     ServerName site1.org
</VirtualHost>

# site2.org
<VirtualHost 12.34.56.78:80>
     DocumentRoot /var/www/html/site2
     ServerName site2.org
</VirtualHost>

Things that didn’t work for me but should be tried:

  1. Deactivating plugins (to avoid WP conflicts)
  2. Verifying that apache has loaded mod_rewrite (it was)
  3. Verifying that the root directory for the WordPress instance had a .htaccess file (it did)
  4. Verifying that .htaccess has something like this: (it did)
    <IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteBase /
     RewriteRule ^index\.php$ - [L]
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule . /index.php [L]
    </IfModule>
    

Note: I also ran into the problem of this code disappearing (apparently) randomly from .htaccess. Turns out that when changing Permalinks from Default to posts (or any other permalink setting actually), WordPress tries to modify the .htaccess file. Because my permissions were set 644 (rw-r–r–) and WordPress runs as the owner, when toggling modes back and forth (on/off), WordPress was editing/re-editing the file. Setting permissions to 444 (r–r–r–) fixed that.

What worked:

The sub-directory in which WP was installed had the right .htaccess, but httpd.conf was not allowing apache to use that file. Specifically AllowOverride was not set to All.

Since I’m using CentOS, my httpd.conf file is in /etc/httpd/conf/. Using vi, I searched for anywhere AllowOverride was set:

# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

This is good. I want my root directory to be locked down. It’s the next section that is the one I want.

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/var/www/html">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
    Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride None

#
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from all

</Directory>

Again, this is fine. Now I need to add exceptions for the specific directories.

#
# allow .htaccess files for wordpress directories
#
<Directory "/var/www/html/site1">
    AllowOverride All
</Directory>

Yay.

Reference that helped:
Setting Up Pretty Permalinks in WordPress Using htaccess and mod_rewrite on Linux (CentOS 6)

July 7, 2014
by puhfu
0 comments

Nothing like a birthday to remind you ….

… of how many websites that have your birthday.

June 30, 2014:

  • VeggieGrill (free entree)
  • Ruby’s Diner (free sundae)
  • IHOP (free Rooty Tooty Fresh ‘N Fruity Pancakes)
  • Farrell’s (free sundae)

July 1, 2014:

  • Office Depot (5% extra reward points in July)
  • Sport Chalet (3x points in July)
  • Cinnamon Productions via SpotOn (free cupcake)
  • Footsmart (15% off)
  • It’s a Grind Coffee House via SpotOn (free small drink)
  • Kimpton Hotels (20% off daily rate, thurs-sun, 2 glasses champagne + dessert, surprise gift, at participating hotels, blackout may apply, booked using code “BUBBLY”)
  • StubHub (free electronic delivery)
  • Starbucks (free drink, 15% off at starbucksstore.com)

July 6, 2014:

  • UCLA Fund

July 7, 2014:

  • AAP
  • FlyerTalk
  • Princess Cruises (animated card)
  • Everton Football Club (okay, a generic birthday message from Roberto Martinez? I’LL TAKE IT.)
  • Everton Direct (£5 off next order of £40)
  • JetBlue TrueBlue (500 points for flight in July)
  • LA Dodgers (15% off next purchase)
  • Tuttle-Click Capistrano Ford ($10 towards next service)
  • Clear (identical email to last year’s email)
  • Facebook (ugh. stalkers.)
  • Kellogg’s (100 Family Rewards points)
  • CafePress ($15 off next order of $50 or more)

October 25, 2013
by puhfu
0 comments

Care and Feeding – Week of 10/21/13

A break from food service on Monday as I was at Penn State Hershey.

Tuesday

We are running out of lunch things. It’s back to PB (Calvin), PB+J (Ian), PB+2J (Olivia).

Wednesday

Pizzadilla (pepperoni, mozzarella, marinara in a quesadilla) for everyone.

Thursday

Pastrami and swiss panini, with arugula.

Friday

Roasted chicken and havarti panini, with avocado for Olivia.