2015-09-04 68 views
1

我有問題,我的htaccess代碼的問題是我不知道我怎麼可以顯示的index.php代碼, 我正在使用的代碼是如何從的index.php htaccess的刪除參數

RewriteEngine On 
    RewriteRule ^Page/([^/]*)$ /Page.php?v=$1 [L] 

和我的輸出鏈接是www.expample.com/Page/1

上述SIS的每一件事情,除了工作的索引頁

什麼,我現在需要做的是

代碼

的index.php,而不是page.php文件

我想這樣

 RewriteRule ^/([^/]*)$ /index.php?v=$1 [L] 

而且它不工作

,我現在需要的是該鏈接從

轉換輸出www.example.com/index.php?v=1www.example.com/1

回答

2

對於第二個index.php規則,您需要使用RewriteCond避免重寫文件或目錄:

Options -MultiViews 
RewriteEngine On 

RewriteRule ^Page/([^/]*)$ Page.php?v=$1 [L,QSA,NC] 

# if request is not for a file 
RewriteCond %{REQUEST_FILENAME} !-d 
# if request is not for a directory 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^/]+)/?$ index.php?v=$1 [L,QSA] 
+1

非常感謝你是的工作 – badr

0

嘗試這個

重寫規則^ 1/$的index.php V = 1 [QSA,L]

我認爲你不應該使用?的index.php嘗試的index.php

0

您可以使用以下規則來重寫你的index.php

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^/]+)/?$ index.php?v=$1 [L] 
0

試試這樣的:

RewriteBase/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index.php/?([^\ \?]*) [NC] 
RewriteRule^%1/%2 [R=301,L] 

這應該處理/index.php的任何位置。