偽靜態常用配置方法
阿新 • • 發佈:2022-04-22
[ Apache ]
httpd.conf配置檔案中載入了mod_rewrite.so模組 AllowOverride None 將None改為 All 把下面的內容儲存為.htaccess檔案放到應用入口檔案的同級目錄下 <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule>
[ IIS ]
在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 ]
location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1last; break; } }