Announcement

Collapse
No announcement yet.

Fixing Pretty Permalinks with Mod_Rewrite in Wordpress Blogs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fixing Pretty Permalinks with Mod_Rewrite in Wordpress Blogs

    I have a client who has chosen Vodahost for her blog. She uploaded the theme for her wordpress blog and I'm customizing it and Optimizing it for search engines.

    The pretty permalinks (Options | Permalinks ) for "Custom Permalinks structure" was not working.

    Default worked, but if I wanted to customize the permalinks for a true representation of the post using the custom permalink structure, it would just fail and come up 404 not found.

    I could get it to work if I tried other things, but it would include the index.php into the url ie: www.domain.com/index.php/uncategorized/post.html

    having the index.php in the url was a bit messed up though and was not as efficient for the search engines as it could be.

    I contacted support and they told me that mod_rewrite was in fact turned on for the vodahost website.

    I finally found this solution:

    The following piece of information from the Using Permalinks codex helped fix the problem:

    Server Blockage: Your host might have blocked the SERVER_SOFTWARE variable and this will cause WordPress' .htaccess generation to fail. If you are sure that your server is running Apache, you can force WordPress to believe that your server is running Apache by changing your wp-includes/vars.php file. Follow the steps below to implement these changes.

    1. Open the wp-includes/vars.php file using the built in file editor in your WordPress Admin panel. To navigate to this panel, login to WordPress, click on "Manage", then on "Files", scroll to the bottom and type in wp-includes/vars.php into the text box under the "Other Files" title.
    2. Look for $is_apache = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? 1 : 0;, once you find it replace it with // $is_apache = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? 1 : 0;
    3. Add a new line under // $is_apache = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? 1 : 0; and type in $is_apache = 1;

    I modified the vars.php file as described above to force WP to believe that Apache was there. Then I reset my permalink options to the default style and deleted the .htaccess that was there.

    I then went back to Permalink options and created the Pretty Permalink style. WP successfully created the new .htaccess with the proper mod_rewrite rules.
    I found the solution above and used it with one modification.

    when I tried to update the vars.php file using the built in editor, it failed to save, so I had to download the vars file to my computer, update it with the line specified in the post above, and then upload the vars.php file again.

    changed the permalinks back to default

    deleted the .htaccess file

    changed the permalinks back to my custom /%category%/%postname%.html and it created the new .htaccess file with the rewrite code updated.

    nice.

    I'm posting this here because it solved the problem I've been looking for for a good 4 or more hours. In fact, I gave up but then the vodahost server crashed - motherboard fried and we lost everything we had done.

    This time, I didn't want to do any modifications or spend too much time on the blog until I had this resolved. This time, I found the answer and used the method above with success.

    I hope this helps with anyone else looking for the answer to pretty permalinks using mod_rewrite with Wordpress and vodahost

    there- that last sentance should index this post with those key phrases for anyone else looking for this solution.
    My Weight Loss Website | Get Ur Links | Article Announcements | Article Website

  • #2
    Re: Fixing Pretty Permalinks with Mod_Rewrite in Wordpress Blogs

    Thank you so much for posting this. I thought I was going mad because I couldn't see my Pages after changing the Permalink.

    In Wordpress 2.3.3 the line to comment out with // looks slightly different, but don't worry about it, just add the line shown

    $is_apache = 1;

    underneath it (after you've put // at the front of the offending line) and it works a treat.

    Comment


    • #3
      Re: Fixing Pretty Permalinks with Mod_Rewrite in Wordpress Blogs

      In Wordpress 2.5.x the offending line is

      $is_apache = ((strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) || (strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false)) ? true : false;

      Put // in front of this line and then add

      $is_apache = 1;

      underneath so the entry should look like this:

      //$is_apache = ((strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) || (strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false)) ? true : false;

      $is_apache = 1;

      Comment

      Working...
      X