有时跟家间服务商说不明白。人家就说你的是源码问题。
就是服务器要支持伪静态,现在服务商应该都支持的
apache 是.htaccess 官方提供的就是这个文件
iis6是 httpd.ini
RewriteRule (.*)$ /index\.php\?s=$1 [I]
iis7是 web.config
<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.conf加入:
location / { // …..省略部分代码 if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } }
以上是tp5默认的,可以自己测试下是否有用。
不知道什么情况,我用的必须上面的找个个规则,也就是tp5默认的,官方那个不行
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
# RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
IIS暂时没研究.
apache的话,默认是支持,就是.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]
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>