2012-04-20 209 views
1

我試過看其他教程和示例,但沒有什麼比較適合我的場景。我htaccess文件是這樣的:htaccess刪除文件夾的文件夾

RewriteEngine on 

rewritecond %{http_host} ^example.com [nc] 
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} !\..+$ 
RewriteCond %{REQUEST_URI} !/$ 
RewriteRule (.*) http://www.example.com/$1/ [R=301,L] 

RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L] 
RewriteRule ^view/([^/]+)/([^/]+)/?$ index.php?page=view&id=$1&title=$2 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([a-zA-Z0-9]+) 
RewriteRule ^([a-zA-Z0-9]+)$ /%1/? [R=301,L] 

ErrorDocument 404 /404 

我使用PHP和需要重寫/index.php?page=page & moreparamaters = 1

但我也有稱爲服務器上的文件夾/管理/我想刪除這些文件的擴展名爲.php這個文件夾中,以便:

/admin/lol.php成爲/admin/lol/

我有很多這些文件,所以我不能真正增加各一,獨立。我怎麼能做到這一點,而不會影響我的index.php重寫?

謝謝

回答

2

你必須思考另一種方式。假設所有的文件直接放置在文件夾中(意味着,沒有子文件夾),這將工作:

RewriteRule ^admin/([^\/]*)? /admin/$1.php [L,R] 

在你的鏈接,那麼你可以寫/管理/笑/或/管理/笑,都將是重定向到/admin/lol.php