官方默認的.htaccess文件

<IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule>
phpstudy規則:
1、確認你的apache開啟rewrite模塊、
2、修改官方文件最后一行
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
apache版本使用上邊的方式無法正常隱藏index.php 可以嘗試使用下邊的方式配置.htaccess文件:
1、確認你的apache開啟rewrite模塊、
2、修改官方文件最后一行,在/$1前邊加一個 ? (注意英文格式半角)
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
Nginx環境,可以在Nginx.conf中添加:
location / { if(!-e $request_filename){ rewrite ^(.*)$ /index.php?s=$1 last; break; } }