WordPress fixed link settings

Source: Internet
Author: User
Tags ftp client godaddy hosting install wordpress microsoft frontpage wordpress blog wordpress forum microsoft iis
Document directory
  • Fixed Link Type
  • Select Permanent Link Structure
  • Use "beautiful" fixed links
  • Do not use a fixed link of mod_rewrite
  • Fixed Link Problems
  • Fixed links,. htaccess files, and MS Frontpage
  • See
  • External resources

Permalink is a permanent URL of blog logs, categories, and other Blog content lists. Other Bloggers can use a fixed link to your article, or you can send a log link in email. The URLs of all logs should be permanent and fixed-this is calledFixedLink.

Fixed Link Type

There are three basic types of WordPress fixed links:

Default type: "Not beautiful"

Default format

http://example.com/?p=N

Here N is the Post ID. It can be used in all server environments, but this form of URL looks not very nice.

Mod_rewrite type: "Beautiful Fixed Link"

These fixed link styles are easy to understand and pleasing to the eye. Although the URL format is diverse, the most common form is

Http://example.com/category/post-name/ or http://example.com/year/month/day/post-name

Some users remove Date Elements (days, months, and years) to simplify the permanent link format.

Beautiful fixed links can work in the following environments:

  • Apache network server with mod_rewrite module
  • Microsoft IIS 7 + network server with URL Rewrite 1.1 + as FastCGI running module and PHP5
  • Use the 404 handler or mod_rewrite or mod_magnet Lighttpd
PATHINFO: "almost perfect"

PATHINFO fixed links are similar to mod_rewrite fixed links. There is only one difference: the former inserts/index. php, as shown below:

http://example.com/index.php/yyyy/mm/dd/post-name/

In addition, PATHINFO is as perfect as mod_rewrite fixed links, and its flexibility is similar. The Fixed Link of mod_rewrite can achieve the same effect. The fixed link of PATHINFO can also be achieved through the/index. php part.

There isPlug-insThe fixed link type in use and details about the internal Rewrite Rules used by WordPress are displayed.

Select Permanent Link Structure

You canSet>Fixed LinkSelect the structure of common fixed links in panel (Options> fixed links in versions earlier than WordPress2.5), or useStructure tagEnter the custom structure in "Custom structure.

Use index. php/as the beginning of the fixed link structure to enable the PATHINFO fixed link.

 

Structure tag

You can use the following tags to customize the "beautiful" or "close to beautiful" Fixed Link. Here are some notes:

  • Make sure to end the fixed link structure with % post_id % or % postname % (for example,/% year %/% monthnum %/% day %/% postname % /)), in this way, each fixed link points to an independent log.
  • Considering the running problems, it is best not to start with a fixed link structure by category, Tag, author, or log name segment. This is because these are all text fields. If the text field is used as the starting part of the fixed link structure, wordPress needs to spend more time determining whether this is a log URL or a page URL (the page URL always uses the "Page alias" as the URL). to compensate, wordPress stores a large amount of additional information in the database (the large amount of information directly affects the operation of websites with multiple pages ). Therefore, it is best to start your Fixed Link Structure with numeric fields such as year or log ID. Refer to the WordPress tester's discussion on this issue.

% Year %

The year of the log, four digits, such as 2009

% Monthnum %

The month of the log, for example, 05.

% Day %

The log publication date, for example, 28

% Hour %

Log posting time (hours), for example, 15

% Minute %

The log posting time (in minutes), such as 43

% Second %

The log posting time (in seconds), for example, 33

% Postname %

The thumbnail version of the log title (on the log/page editing pageLog alias). Therefore, "This Is A Great Post !" This-is-a-great-post is returned in the URI.

% Post_id %

Unique log ID, such as 423

% Category %

Scale-down version of the category name (on the Add new category/Edit pageCATEGORY alias). Nested subcategories appear in the URI as nested subdirectories.For running purposes, % category % is not recommended as the starting part of the fixed link.

% Tag %

Scale-down version of the tag name (Add a new tag/editLabel alias).For running reasons, we do not recommend using % tag % as the starting part of the fixed link.

% Author %

The thumbnail version of the author name.

Classification library and tag Library

The category library and tag library are prefix used in the category and tag archive URL, similar:

Example.net/wp/category_base/category_name
Example.net/wp/tag_base/tag_name

The default values are classification and label. You can change the default values, but cannot remove them from the URL.

Custom fixed links can run in many systems without barriers, but some exceptions may occur under some conditions.

Use % category % (% tag %) for log URLs with multiple categories)

When you set multiple categories for a log, the log link can only display the category name with the smallest category ID (see article> category directory ). However, this log can be found through other categories.

The same is true for tags.

Use "beautiful" fixed links

Prerequisites:

  • Apache network server with mod_rewrite module
  • Under the WordPress main directory
    • Enable FollowSymLinks
    • Allow FileInfo directives (such as AllowOverride FileInfo or AllowOverride All)
    • One. htaccess file (if this file is missing, WordPress will try to create a new file when the user activates the beautiful Fixed Link)
    • If you want WordPress to automatically update the. htaccess file, you must grant the write permission to the file to WordPress.
  • For more information about Lighttpd, see external resources at the end of the article.

After you create or update a "beautiful" Fixed Link Structure, WordPress will generate a rewrite rule and try to insert the rewrite rule into the appropriate. htaccess file. If WordPress cannot insert rewrite rules. the htaccess file will display You shocould update your. htaccess now (please upgrade your. htaccess file), and then output the rewrite rules, so that you can copy and paste the rules to the file (put the rules at the end of the file ).

In WordPress 2.0 and later versions, you may only need to execute more than once, because WordPress runs Rewrite Rules internally. If you move the WordPress home directory address (blog address), you need to repeat the above actions.

WordPress works with existing. htaccess files and does not delete any existing rewrite rules or other commands. If you have other mod_rewrite rules, give priority to the mod_rewrite rules generated by WordPress.

Where is my. htaccess file?

The index. php and. htaccess files of the WordPress blog should be locatedSet>GeneralUnder the blog address (URI) folder set in the menu. Because the file name of the. htaccess file starts with a period, you may not be able to view the file through the FTP client unless you modify the preference of the FTP tool to display all files including hidden files. Some virtual hosts (such as Godaddy) do not allow users who install WordPress through Godaddy Hosting Connection to view or edit the. htaccess file.

Create and edit a. htaccess File

If you do not have a. htaccess file, create one first. If you have shell or ssh permissions on the server, you can use a simple touch. htaccess command to create a. htaccess file. If you use FTP to transfer files, you can create a new one on the local machine. the htaccess file named 1. htaccess, set 1. upload htaccess to the root directory of the WordPress File and rename it. htaccess.

You can edit the. htaccess file through FTP, shell, or (possibly) the control panel of your VM.

If your. htaccess file contains errors that can cause website paralysis ("Internal Server Error (500)"), you need to use FTP or the control panel of the VM to delete the rogue. htaccess file.

Automatically update the. htaccess File

If WordPress cannot automatically update your. htaccess file, it willSet>Fixed LinkIf your. htaccess file were writable, we cocould do this automatically, but it isn' t... (If your. htaccess file is writable, we can help you automatically update it, but your. htaccess file cannot be written.

If you want WordPress to automatically update the. htaccess file, you must grant the write permission to the file to WordPress. The required permissions depend on your server settings. Try to grant the owner the write permission, and then assign the group permission, and then the write permission of the Service world. Each modification requires a test. Once WordPress can edit the file successfully, no additional permissions are required.

After using a fixed link, you should increase the permission to 660 or 644 to prevent access from other users on the server.

Do not use a fixed link of mod_rewrite

Mod_rewrite is usually required for "beautiful" fixed links, while mod_rewrite is not supported for IIS (common on Windows servers. (If you use Apache 2.0.54 on Windows, mod_rewrite may run, provided that mod_rewrite is activated in apache \ conf \ httpd. conf ).

When you use IIS 7 and have server management rights, you can use the URL rewriting module of Microsoft to replace mod_rewrite. Although IIS 7 is not fully compatible with mod_rewrite, it supports fixed links of WordPress. After Microsoft's URL rewriting module is installed, open the web. config file in the WordPress directory and add the following rules to the system. webServer element:

<Rewrite>
<Rules>
<Rule name = "Main Rule" stopProcessing = "true">
<Match url = ". *"/>
<Conditions logicalGrouping = "MatchAll">
<Add input = "{REQUEST_FILENAME}" matchType = "IsFile" negate = "true"/>
<Add input = "{REQUEST_FILENAME}" matchType = "IsDirectory" negate = "true"/>
</Conditions>
<Action type = "Rewrite" url = "index. php"/>
</Rule>
</Rules>
</Rewrite>

The IIS website provides a detailed installation guide for the Microsoft URL rewriting module, which can be used in x64 and x86 systems.

If this method does not work, try the PATHINFO link. Place index. php/before the start of the custom link structure:

/index.php/%year%/%monthnum%/%day%/%postname%/  

This method is not always successful, especially when running WordPress on ISS 6. To make this method run on IIS, you need to add the following two lines of code to the php. ini file and save the file under the Network root directory (http://blog.taragana.com/index.php/archive/wordpress-tip-on-permalink-options ):

Cgi. fix_pathinfo = 1
Cgi. force_redirect = 0

Another solution is to use custom 404 redirection of IIS. This requires that your VM allow you to add custom 404 redirection. However, you do not need to install any third-party mod_rewrite software or your fixed link structure to/index. php.

  • Http://www.keyboardface.com/IIS-Permalinks/
  • Another very simple custom 404 redirection solution: http://tech.einaregilsson.com/2007/07/30/pretty-wordpress-permalinks-on-iis/
  • New version of the above solution: http://www.ikailo.com/94/url-modrewrite-workaround-iis-60/

If you have the permission to manage the server, you can try the following solutions:

  • WordPress URL Rewrite Plugin for blogs running on IIS
  • URL Rewriting for WordPress under IIS
Fixed the fixed link issue. Fixed the issue that occurred when generating. htaccess.

If your WordPress does not generate a. htaccess file, or you do not write new rules for the existing. htaccess file, there may be many reasons. Follow the instructions below. If a step is invalid, proceed to the next step.

1.Change File Permissions: You must. change the permission of the htaccess file to 666, and then use the WordPress template editor to edit the file. However, we do not recommend this operation if you use the template table and edit it. htaccess, so all users on your blog who have the right to edit the template can edit your. htaccess file. You can change the File Permission to 666 so that the file can be written to the server, which achieves the same protection effect.

2.Server Blocking: Your VM may have locked the server_SOFTWARE variable, causing WordPress to fail to generate a. htaccess file. If you are sure that your server is running Apache, you can change the wp-DES/vars. php file and force the command WordPress to believe that your server is running Apache. Follow these steps to change the wp-DES/vars. php file.

  • Edit the wp-nodes des/vars. php file. Find in the file:

$ Is_apache = strstr ($ _ SERVER ['server _ soft'], 'apache ')? 1: 0;

Replace it with the following code:

// $is_apache = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? 1 : 0;
  • In
    // $is_apache = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? 1 : 0;

    Enter:

    $is_apache = 1;

3. XAMPP (Windows) Users: some versions of XAMPP do not activate mod_rewrite by default (though this is compiled using Apache ). To activate mod_rewrite -- and activate WordPress write. htaccess file (used to create beautiful fixed links) -- you need to open apache/conf/httpd. conf to cancel the annotation mark (for example, deleting the # symbol before the code line) of LoadModule rewrite_module modules/mod_rewrite.so ).

Fixed links,. htaccess files, and MS Frontpage

About Microsoft Frontpage: many servers (including shared servers and dedicated servers) created and maintained by virtual host service providers are equipped with mod_frontpage built by apache, in most cases, the Front Server extensionserver option is installed on each virtual Server. Most of today's virtual hosts are commercially available. The binary release package during server creation contains both mod_frontpage and server extensions. Because of plug-ins and apache (and httpd. conf file), even if you do not use Frontpage, if you try to view your WP installation, 500 error may occur or you can see a blank page, this is because your server has extensions/mod_frontpage.

WordPress works smoothly with the installed Frontpage extension option, but the fixed link does not work properly, because. the mod_rewrite rules attached to the htaccess file will make any changes to the fixed link menu on the WordPress Management Panel, leading to the failure of the Frongpage server expansion option.Fortunately, there is a way to solve this problem..

Quick Fix of Frontpage or fixed link

Fixed Frontpage extension options: If you don't care about the fixed connection, you only need to edit the. htaccess file and delete the rewrite rules of the WordPress part if you want the extended options of the MS Frontpage Server to run properly.

Use a fixed link: If you don't care whether Frontpage can run properly (but the VM provider has the Frontpage extension option installed), you need to delete (or let your VM provider delete) The MS Frontpage Server Extension option, you can also edit. htaccess file to delete all front page code lines, leaving only the WordPress mod_rewrite code.

Use both Frontpage and Fixed Link

This is the final solution.

Many discussions on simultaneous use of Frontpage and fixed links on WordPress Support forums have not yet come up with an effective solution.

Under normal circumstances, on a Unix server with the Microsoft Frontpage Server Extension option installed, WordPress can run properly. You can also (use Microsoft FrontPage) edit and publish various pages -- until -- you have modified the fixed link (for example, changing the fixed link to the date-based index type,/2009/04 /). For example with a fixed link, we always use a link of the date type because this is a W3C recommended usage (see http://www.w3.org/Provider/Style/URI ).

The problem now is that Frontpage uses the. htaccess file (the file that is required by the WordPress mod_rewrite rule) for "publishing" and "Network editing ". After the WordPress mod_rewrite code is added to the. htaccess file, there are two consequences: one is that fixed links cannot play a role, and the other is that the Frontpage Server expansion option is paralyzed.

Someone tried to use the rewrite rule "Ignore" Frontpage's % {HTTP_USERAGENT) % "to override httpd. the conf file uses another AccessFilename. wpaccess file and other settings, but this does not work.

By accident, we found a very simple solution.

If a WordPress user wishes to use or is using Frontpage (or the virtual host package you purchased has configured Frontpage in advance ), perform the following operations on the server or ask your VM provider to perform the following operations for you.

Microsoft Frontpage creates the following folder:

_vti_bin

The folder is also nested and created:

_vti_adm

And

_vti_aut

In the preceding folder, you can view the root directory of your website (or WordPress) and other. htaccess files.

In the preceding three folders and root folders, add the following code at the top of all. htaccess files:

Options +FollowSymlinks  

The following line of code may already exist in the folder (or may not exist:

Options None

Edit and save all. htaccess files! Then, every program, including Frontpage and fixed link, can run normally.

Long Fixed Link

If the email, comment, or chat content contains too long fixed link addresses, some of the fixed links may be "disconnected", or only the first half of the links are regarded as links by the system, the second half is regarded as text information. For example,

Http://yourdomain.example.com/2005/10/4/article-about-joe-fred-sally-and-bog

It may be seen:

Http://yourdomain.example.com/2005/10/4/article-about-joe-fred-sally-and-bog

Click the link below to display the 404 error page-the page is not found. If you want to use a fixed link with a long log title, follow these steps to avoid the above situation.

1. Make sure you are usingFixed Link

2. Edit the. htaccess file and add the following content to it:

 RewriteRule ^post/([0-9]+)?/?([0-9]+)?/?$ /index.php?p=$1&page=$2 [QSA]  

3. perform the test. Select the ID of a log and enter the following content in the browser (replace yourdomain with your domain name, the ID # With your log ID ), when the page jumps to the selected log page, the test is successful:

http://yourdomain.example.com/post/(the ID #)  

Most e-mail software does not cut the link URL with Angle brackets (<and>). Therefore, to copy the URL address in e-mail, use the following format:

Welcome to read my new log

In addition, some advanced email clients provide a "pre-Orchestration format" option for users who write plain text emails. If you use the pre-Orchestration format when copying a link address, the email client will not insert a line break into the link.

Fix other problems

If the generated. htaccess file is correct, but the fixed link is still unavailable, it may be for the following reasons. If the problem persists, visit the WordPress forum for help.

AllowOverride not activated

You cannot use a fixed link, probably because your server may not activate the AllowOverride command. If the AllowOverride command in the httpd. config file of Apache is set to None, the. htaccess file will be completely ignored, and the server will not be able to read the. htaccess file in the file system. When the AllowOverride command is set to All, the. htaccess file permits All commands with. htaccess Context.

The AllowOverride command activated in httpd. config:

<Directory/>
Options FollowSymLinks
AllowOverride All
</Directory>

You may also need to activate the AllowOverride command in the root directory of the file:

<Directory/var/www/html>
#... Other directives...
AllowOverride All
</Directory>

In addition, you also need to change the website's AllowOverride settings, especially when using the Mac OS X Server, but other operating systems may also be the same. You can usually find the website configuration file in/etc/httpd/sites.

If you do not want to set AllowOverride to All, the FileInfo command must be included in your AllowOverride list. In addition, you need to restart the Apache server to make the changes to httpd. config take effect. For more information about license rewriting rules, see Apache Core Features.

Paging navigation cannot work

The paging navigation of logs sometimes does not work properly. The log generates a page link with the following URI:

Http://www.example.com/page/2/
Http://www.example.name/category/categoryname/page/2/
Http://www.example/year/month/day/page/2/
Http://www.example/year/month/page/2/

Click any link on the page. All the surrounding elements (page header, footer, and sidebar) are displayed, but the body is missing. An error message is displayed in the body of the page: "Sorry, no logs matching the requirements are found."

This is caused by a small error in the. htaccess file generated by WordPress. To correct this small error, You need to delete the content in the. htaccess file and recreate a. htaccess file.

1. Find the. htaccess file on the local machine.

2. copy and paste the file content to the text editor and save it as a text file. This is a precaution to prevent manual content input in the. htaccess file by htaccess methods such as redirection and Access denied.

3. Delete and save the content in the. htaccess file and upload the file to the FTP client.

4. Go to the WordPress website management page and selectSet>Fixed Link

5. Click "Save changes" to regenerate the rewrite rule for the fixed link.

6. Access the previous error link and test the operation result.

7. log on to FTP and add manually entered content to the. htaccess file (place the manual entry before # BEGIN WordPress or after # END WordPress .)

It can also be deleted from the server. create an empty htaccess file. in the htaccess file, change the File Permission to 666, and click "Save changes" in the Settings> fixed link to generate a new htaccess rule.

If it still does not work, check this post on the WordPress forum.

The fixed link on the page is invalid.

Are you tired of the process of "accessing new pages> encountering errors? In fact, you can update the fixed link structure without having to worry about it any more. Remember, every time you add a new static page to a WordPress website, you must generate a new rule and add it. in the htaccess file (WordPress 1. X Series) or add to the internal rewrite array (WordPress 2. X Series ).

The fixed link on the Ultimate Tag Warrior tab is invalid.

In WordPress 2. when the Ultimate Tag Warrior plug-in is used in the X Series, sometimes the 404 error occurs when accessing the local Tag link. This is because the internal rewrite rules generated by WordPress are too greedy ", interference is added before the rewrite rules of the plug-in can be run. However, this usually only happens in the Custom fixed link structure (for example,/% postname % /). To fix this problem, you can change the fixed link structure to "date and document name", or modify the Ultimate Tag Warrior plug-in to store the rewrite rules at the top of the internal rewrite array. For more information, see here.

You can use a fixed link, but no page is returned.

Some versions of PHP 4.4.x and PHP 5.x have a bug: mod_rewrite cannot run when Apache 2.x is used. See http://bugs.php.net/bug.php for details? Id = 35096 with http://bugs.php.net/bug.php? Id = 35059.

More help

If none of the above methods can restore the fixed link to normal, please find the answer in the WordPress manual, troubleshooting or forum. You can submit a bug report to WordPress.

Tips

If you want your website to appear in the Google News list, first, your website must meet a required condition: each link should end with an identifier with at least three digits.

This condition can be easily met using the % postname %-% post_id % structure that adds a log ID to the end of the URL to make the URL structure formatted as: http://mysite.com/cooking-tips-tricks-344

End with .html as the log URL

Using the structure label that you pull to quickly give your website a. html extension. Follow the example of ending a fixed link in the previous article to obtain a page with the link http://yoursite.com/2006/01/01/happy-newyear.html. The rewrite rule for the page is:

 /%year%/%monthnum%/%day%/%postname%.html  

Otherwise, the static. html file will not be generated. It is only a log file. html extension, and the webpage is still dynamically generated. We can argue that this kind of operation is more advantageous than seo, but after the name is expanded by Japanese character .html, the page can be quickly converted to a static page, but the URL structure is still retained.

Prevent log links from being resolved to archive links

The link structure similar to % year r % month % day % may be considered as the log archiving link for that day (if more than one log is published on that day ), therefore, at least % years % months % days % hours % must be used as a link to a single log.

Check the Fixed Link Structure

There is one way to check whether the website has a fixed link:

if ( get_option('permalink_structure') != '' ) { echo 'permalinks enabled' }
See

Content Link

External resources
  • Optimize WordPress Permalinks
  • Beauw.your URLs with Permalinks
  • How to Configure WordPress to Create Search Engine Friendly URLs for Permalinks
  • The htaccess Rules for all WordPress Permalinks
  • URL Rewriting Tutorial
  • Boost Search Engine Optimisation (SEO) using Permalinks
  • Understanding WordPress Permalinks
  • WordPress Permalink Canonicalization using htaccess
  • Customize and Optimize Your Dated WordPress Permalinks
  • Clean Permalinks for IIS using. htaccess
  • The Easiest Lighttpd Rewrite Rule
  • URL rewriting with lighttpd
  • Permalinks with Lighttpd

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.