1

我的网站根文件夹中有这样的 .htaccess:

DirectoryIndex index.php
RewriteEngine On

Options -indexes

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php

这是由一些已安装的 CMS 创建的。

我有一个名为的文件夹,例如,test在根文件夹中。问题是:

  • 如何从全局(根 htaccess)重写规则中删除此文件夹

  • 这个文件夹有它自己的htaccess。在那里添加什么以允许我这样做:

   site.com/test/some-data
   --->
   site.com/test/?id=some-data
4

2 回答 2

1

如果我理解正确,您可以在根目录的 .htaccess 文件中尝试此操作:

Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} !index\.php     [NC]
RewriteCond %{REQUEST_URI} !test           [NC]
RewriteRule (.*)           index.php       [L,NC]

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^test/([^/]+)/? /test/?id=$1   [L,NC]

目录中不需要另一个 .htaccess 文件/test。只使用这个。

于 2013-03-05T16:04:35.847 回答
0

如果你想在你的测试目录中有一个单独的 .htaccess,这个就足够了

RewriteEngine On

RewriteCond %{QUERY_STRING} !.
RewriteRule .+ ?id=$0
于 2013-03-05T18:13:58.753 回答