.htaccess文件_WordPress的.htaccess文件是天才

.htaccess文件

Choosing to use WordPress was a more difficult decision that you may think. Sure, WordPress is the most used blogging software on the internet, but I'm a programmer, right? I should want to code everything myself, right? I thought that at first but I decided to try WordPress first and I've been impressed with every part of WordPress so far. One of the interesting parts of WordPress is the URL rewriting and "slug" that gets created for each post. How did they do that?

您可能会认为,选择使用WordPress是一个比较困难的决定。 当然,WordPress是互联网上最常用的博客软件,但是我是程序员,对吗? 我应该自己编写所有代码,对吗? 最初我以为是这样,但我决定先尝试WordPress,到目前为止,WordPress的每个部分都给我留下了深刻的印象。 WordPress有趣的部分之一是为每个帖子创建的URL重写和“ slug”。 他们是怎么做到的?

Well, I know enough about SEF (search engine friendly) links to know that an .htaccess file had to be involved so I downloaded the .htaccess file from my hosting server and saw:

好吧,我对SEF (搜索引擎友好)链接了解得足够多,知道必须包含.htaccess文件,因此我从托管服务器下载了.htaccess文件,并看到:


   
   
    
    
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

   
   

That's it? Yep. Basically, the flow goes as follows:

而已? 是的 基本上,流程如下:

  1. We must first establish that mod_rewrite is available on the server

    我们必须首先确定mod_rewrite在服务器上可用
  2. If so, turn on mod_rewrite

    如果是这样,请打开mod_rewrite
  3. Set the base of all rewriting to the web root folder

    将所有重写的基础设置到Web根文件夹
  4. If the requested filename isn't a file....

    如果请求的文件名不是文件...。
  5. ....and it isn't a folder...

    ....这不是文件夹...
  6. Send the person to index.php

    将该人发送到index.php

Once inside the index.php file, the index.php file processes the request and presents you with the page based upon the slug in the URL. Very simple .htaccess code runs a reliable WordPress blog.

进入index.php文件后, index.php文件将处理请求,并根据URL中的链接向您显示页面。 非常简单的.htaccess代码可运行可靠的WordPress博客。

翻译自: https://davidwalsh.name/wordpress-htaccess

.htaccess文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值