dongqianchi0512 2010-11-27 19:21
浏览 45
已采纳

wordpress SEO友好网址是否可以在不使用htaccess的情况下工作?

Wordpress uses friendly seo url without using htaccess.

Can any explain this to me please how they do it.

The only way i can think of is to do something like this.

domain.com/index.php/nnn/mmmm/

But wordpress does not use index.php

I know they are not using htaccess.

Please let me know.

Thank you.

  • 写回答

4条回答 默认 最新

  • dongnuochen9449 2010-11-27 19:41
    关注

    WordPress actually has a single .htaccess file that they don't need to change which redirects all requests to index.php

    index.php then looks at the permalinks rules and runs a few database queries to determine which page to send you.

    So for instance if the permalink rule is %postdate%/%postname% (may not be the actual WordPress permalink variables. I haven't been using WordPress for too long) then it would just use regular expressions (or combinations of substr() and strpos()) to put %postdate% and %postname% into variables. Next it runs a simple database query for any item matching that date and that name. If nothing is found, redirect to search. If you find more than one, list them all (like a category page). If you find one and only one, send that page.

    As far as actually "sending" the page, that's just a matter of settings certain variables (such as $the_post['content']) and then include()'ing the proper theme file.

    include()'ing the theme file is a simple if() statement.

    if(file_exists("wp-content/themes/<your_theme>/$the_post['type'].php")){
        include("wp-content/themes/<your_theme>/$the_post['type'].php");
    } else {
        include("wp-content/themes/<your_theme>/index.php");
    }
    

    Mind you these aren't the exact variable names or the exact functions as they occur. This is just a very simplified version to give the general idea of how these systems work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?