# URL Rewrite\(偽靜態\)設置方法
---
1. 配置偽靜態環境 apache,iis,nginx配置環境不同
1. 系統修改偽靜態配置:
./application/config.php下面修改配置:
define\("REWRITE\_MODEL", true\); 配置偽靜態設置為true 默認false
偽靜態環境配置:
```php
\[ Apache \]
1. httpd.conf配置文件中加載了mod\_rewrite.so模塊
2. AllowOverride None 將None改為 All
\[ IIS \]
如果你的服務器環境支持ISAPI\_Rewrite的話,可以配置httpd.ini文件,添加下面的內容:
RewriteRule \(.\*\)$ /index\.php\?s=$1 \[I\]
在IIS的高版本下面可以配置web.Config,在中間添加rewrite節點:
<rewrite>
<rules>
<rule name="OrgPage" stopProcessing="true">
<match url="^\(.\*\)$" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP\_HOST}" pattern="^\(.\*\)$" />
<add input="{REQUEST\_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST\_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" />
</rule>
</rules>
</rewrite>
\[nginx\]
在Nginx低版本中,是不支持PATHINFO的,但是可以通過在Nginx.conf中配置轉發規則實現:
location / {
if \(!-e $request\_filename\) {
rewrite ^\(.\*\)$ /index.php?s=$1 last;
break;
}
}
```