2015-02-23 108 views
0

我想改變htaccess的重寫規則刪除子文件夾

example.com/modules/page/page.php 

example.com/page 

我有工作的一個部分重寫規則,但有一個問題。如果我鍵入example.com/page/randomstring

RewriteRule ^page/(\w+)/? modules/page/page.php?page_id=$1 [NC,L] 

page.php文件可以訪問我想這僅僅example.com/page

有效我怎樣才能做到這一點?

回答

1

在.htaccess文件

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([A-Za-z0-9]+)$ modules/page/page.php?page_id=$1 [L,QSA]