htaccess删除文件夹的文件夹
问题描述:
我试过看其他教程和示例,但没有什么比较适合我的场景。我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重写?
谢谢
答
你必须思考另一种方式。假设所有的文件直接放置在文件夹中(意味着,没有子文件夹),这将工作:
RewriteRule ^admin/([^\/]*)? /admin/$1.php [L,R]
在你的链接,那么你可以写/管理/笑/或/管理/笑,都将是重定向到/admin/lol.php