2014-02-06 109 views
1

如果$ 1對'索引'沒有任何意義,我該如何重寫?.htaccess:不需要重新編寫索引

Options +FollowSymLinks +ExecCGI 

<IfModule mod_rewrite.c> 

RewriteEngine On 
RewriteCond %{REQUEST_URI} !/assets 
RewriteRule (.*) index.php?p=$1 [QSA] 

</IfModule> 

實施例:

如果我去mysite.com/test輸出是

陣列([P] =>試驗)

當我走到mysite.com的輸出是:

Array( [p] =>)

那麼,當我到mysite.com時,如何將$ 1重寫爲'index'呢?像這樣:

mysite.com:

陣列([P] =>指數)

回答

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]