如果1美元没有'索引',我该如何重写?
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !/assets
RewriteRule (.*) index.php?p=$1 [QSA]
</IfModule>
示例:
如果我去mysite.com/test,输出是
数组([p] =&gt;测试)
当我去mysite.com时输出是:
数组([p] =&gt;)
那么,当我去mysite.com时,如何将$ 1重写为'index'?像这样:
mysite.com:
数组([p] =&gt;索引)
答案 0 :(得分:1)
使用此代码:
RewriteEngine On
RewriteCond %{REQUEST_URI} !/(assets|index\.php) [NC]
RewriteRule ^/?$ index.php?p=index [L,QSA]
RewriteCond %{REQUEST_URI} !/(assets|index\.php) [NC]
RewriteRule ^(.+)$ index.php?p=$1 [L,QSA]