• 懒鸟飞:精品网站源码、帝国cms模板专业分享平台

wordpress伪静态设置方法

有一部分同学在设置 wordpress 插件以后,出现链接不能访问的情况,请按照以下办法解决:
以下方法适用于 Windows 平台下的程序,如果是 Linux 平台请参考2楼的帖子


方法一:新建一个记事本,将以下文件粘贴到记事本里面,然后保存为 httpd.ini ,并上传到网站根目录。
  1. [ISAPI_Rewrite]

  2. # Defend your computer from some worm attacks

  3. #RewriteRule .*(?:global.asa|default.ida|root.exe|..).* . [F,I,O]

  4. # 3600 = 1 hour

  5. CacheClockRate 3600

  6. RepeatLimit 32

  7. # Protect httpd.ini and httpd.parse.errors files

  8. # from accessing through HTTP

  9. # Rules to ensure that normal content gets through

  10. RewriteRule /tag/(.*) /index.php?tag=$1

  11. RewriteRule /software-files/(.*) /software-files/$1 [L]

  12. RewriteRule /images/(.*) /images/$1 [L]

  13. RewriteRule /sitemap.xml /sitemap.xml [L]

  14. RewriteRule /favicon.ico /favicon.ico [L]

  15. # For file-based wordpress content (i.e. theme), admin, etc.

  16. RewriteRule /wp-(.*) /wp-$1 [L]

  17. RewriteRule /wap(.*) /wap$1 [L]

  18. # For normal wordpress content, via index.php

  19. RewriteRule ^/$ /index.php [L]

  20. RewriteRule /(.*) /index.php/$1 [L]

 

方法二:将下面代码保存为 404.php ,进入空间面板,设置这个 404 页面即可。
  1. <?php

  2. // This is the default file for the site. Usually index.php

  3. $default = ‘index.php’;

  4.  

  5. // The name of this file.

  6. // Set this value for the URL in Custom Error Properties of your website in IIS.

  7. // Goto: IIS Manager > Websites > [Site Name] > Properties > Custom Errors >

  8. // 404 & 404;2 & 404;3 > URL (Requires a ‘/’ prefix in IIS).

  9. $thisfile = ’404.php’; //404.php修改为你的404页面名称即可

  10.  

  11. $_SERVER['ORIG_PATH_TRANSLATED'] = str_replace($thisfile, $default, $_SERVER['ORIG_PATH_TRANSLATED']);

  12. $_SERVER['SCRIPT_FILENAME'] = str_replace($thisfile, $default, $_SERVER['SCRIPT_FILENAME']);

  13. $_SERVER['ORIG_PATH_INFO'] = str_replace($thisfile, $default, $_SERVER['ORIG_PATH_INFO']);

  14. $_SERVER['SCRIPT_NAME'] = str_replace($thisfile, $default, $_SERVER['SCRIPT_NAME']);

  15. $_SERVER['PHP_SELF'] = str_replace($thisfile, $default, $_SERVER['PHP_SELF']);

  16. $_SERVER['PATH_INFO'] = false;

  17.  

  18. $qs =& $_SERVER['QUERY_STRING'];

  19. $ru =& $_SERVER['REQUEST_URI'];

  20. $pos = strrpos($qs, ‘://’);

  21. $pos = strpos($qs, ‘/’, $pos + 4);

  22. $_SERVER['URL'] = $ru = substr($qs, $pos);

  23. $qs = trim(stristr($ru, ‘?’), ‘?’);

  24.  

  25. // Required for WordPress 2.8+

  26. $_SERVER['HTTP_X_ORIGINAL_URL'] = $ru;

  27.  

  28. // Fix GET vars

  29. foreach ( $_GET as $var => $val ) {

  30. if ( substr($var, 0, 3) == ’404′) {

  31. if ( strstr($var, ‘?’) ) {

  32. $newvar = substr($var, strpos($var, ‘?’) + 1);

  33. $_GET[$newvar] = $val;

  34. }

  35. unset($_GET[$var]);

  36. }

  37. break;

  38. }

  39. include($default);

  40. ?>
 
QQ在线咨询
QQ客服
淘宝官网