这个mod重写在htaccess文件中做了什么?

时间:2014-06-16 17:15:11

标签: apache .htaccess mod-rewrite

我有一些ht代码,我只想

知道这段代码到底做了什么?

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !public
RewriteCond %{REQUEST_URI} !robots.txt
RewriteRule . /index.php [L]
</IfModule>

1 个答案:

答案 0 :(得分:1)

  1. 第一条规则会从您的网址中删除www
  2. 第二条规则跳过/index.php
  3. 的重写
  4. 第3条规则将除/public/robots.txt以外的所有URI重写为/index.php
  5. 参考文献:

    1。 Apache mod_rewrite Introduction

    2。 Apache mod_rewrite Technical Details