How to Ensure Your WordPress Permalinks Work with Your Server

After you set the format for the permalinks for your site by using any options other than the default, WordPress writes specific rules, or directives, to the .htaccess file on your web server. The .htaccess file in turn communicates to your web server how it should serve up the permalinks, according to the permalink structure you’ve chosen to use.


To use an .htaccess file, you need to know the answers to two questions:



  • Does your web server configuration use and give you access to the .htaccess file?



  • Does your web server run Apache with the mod_rewrite module?




If you don’t know the answers, contact your hosting provider to find out.


If the answer to both questions is yes, proceed to the next section. If the answer is no, skip to the “Working with Servers That Don’t Use Apache mod_rewrite” section.


Creating .htaccess files


You and WordPress work together in glorious harmony to create the .htaccess file that lets you use a pretty permalink structure in your blog. To create an .htaccess file on your web server and set the correct permissions for it, follow these steps:



  1. Using a plain-text editor, such as Notepad (Windows) or Textmate (Mac), create a blank file, name it htaccess.txt, and upload it to your web server via FTP.


    You may not have to create the file (as instructed in Step 1); if the .htaccess file already exists, you can find it in the root of your directory on your web server, that is, the same directory where you find your wp-config.php file. If you don’t see it in the root directory, try changing the options of your FTP client to show hidden files. (Because the .htaccess file starts with a period, it may not be visible until you configure your FTP client to show hidden files.)



  2. After the file is on your web server, rename the file .htaccess (notice the period at the beginning) and make sure that it’s writable by the server by changing permissions to either 755 or 777.



  3. Create the permalink structure in the Permalink Settings page in your WordPress Dashboard.



  4. Click the Save Changes button at the bottom of the Permalink Settings page.


    WordPress inserts into the .htaccess file the specific rules necessary for making the permalink structure functional in your blog.




Now you have an .htaccess file on your web server that has the correct permissions set so that WordPress can write the correct rules to it. Your pretty permalink structure works flawlessly.


If you open the .htaccess file and look at it now, it’s no longer blank. The file should have a set of rewrite rules code, which looks something like this:


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

If you want to unlock more mysteries about .htaccess, check out javascripkit.com.


Working with servers that don’t use Apache mod_rewrite


Using permalink structures requires that your web hosting provider has a specific Apache module option, mod_rewrite, activated on its servers. If your web hosting provider doesn’t have this option activated on its servers or if you’re hosting your site on a Windows server, the custom permalinks work only if you type /index.php in front of any custom permalink tags.


For example, create the custom permalink tags like this:


/index.php/%year%/%month%/%date%/%postname%/

This format creates a permalink like this:


http://yourdomain.com/index.php/2008/02/01/wordpress-for-dummies

You don’t need an .htaccess file to use this permalink structure.


Yahoo! hosting doesn’t allow users access to the .htaccess file on their servers, and it doesn’t utilize mod_rewrite. So if you’re hosting on Yahoo!, you need to use the custom permalink technique described here.




dummies

Source:http://www.dummies.com/how-to/content/how-to-ensure-your-wordpress-permalinks-work-with-.html

No comments:

Post a Comment