.htaccess 如何在不干扰文件夹名的情况下使用htaccess重写URL?

.htaccess 如何在不干扰文件夹名的情况下使用htaccess重写URL?,.htaccess,url,mod-rewrite,url-rewriting,.htaccess,Url,Mod Rewrite,Url Rewriting,我不是很确定这个标题,但是我怎样才能用.htaccess做到这一点呢 test.com/marketplace/index.php?type=1 对此 test.com/marketplace/1 其中marketplace是服务器上的实际文件夹。 我试过了 RewriteRule^marketplace/([^/]*)$/marketplace/index.php?type=$1[L] 但是没有运气。你要做什么(您需要排除要重写的目标 RewriteEngine on RewriteCond

我不是很确定这个标题,但是我怎样才能用.htaccess做到这一点呢

test.com/marketplace/index.php?type=1

对此

test.com/marketplace/1

其中marketplace是服务器上的实际文件夹。 我试过了

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


但是没有运气。你要做什么(

您需要排除要重写的目标

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/marketplace/index\.php$ [NC]
RewriteRule ^marketplace/([^/]*)$ /marketplace/index.php?type=$1 [L]

否则您会得到一个
无限循环
错误,因为模式
^marketplace/([^/]*)$
也与目标路径
/marketplace/index.php?type=$1

是否激活了重写引擎?是的,重写引擎上会出现什么错误消息?错误消息?我在哪里查找?尝试添加[QSA]旗帜