Apache重写模块:规则详解

1,开其重写模块:

  sudo a2enmod rewrite


2,配置为可重写: 

  打开 /etc/apache  

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

在项目目录下,新建 .htaccess文件,加入以下内容:

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On
  RewriteBase /

  #重写条件
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f

  #重写规则
  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

3,重写规则:

  

  

  


原文地址:https://www.cnblogs.com/canbefree/p/4168885.html