Php 重写规则在.htaccess文件中不起作用

Php 重写规则在.htaccess文件中不起作用,php,html,.htaccess,mod-rewrite,redirect,Php,Html,.htaccess,Mod Rewrite,Redirect,我在Stack上发现了几个问题,这些问题展示了很多例子,但我试过书中的每个人,但都不起作用 我正在努力改变信仰 www.domain.com/title/index.php?id=70048305 到 我希望它能双向转换。当他们使用查询字符串和干净的url键入时 我的重写有什么问题 Options +FollowSymLinks RewriteEngine on RewriteRule ^title/(.+)$ index.php?id=$1 [L,QSA] 我应该注意,我已将此.htacc

我在Stack上发现了几个问题,这些问题展示了很多例子,但我试过书中的每个人,但都不起作用

我正在努力改变信仰

www.domain.com/title/index.php?id=70048305

我希望它能双向转换。当他们使用查询字符串和干净的url键入时

我的重写有什么问题

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^title/(.+)$ index.php?id=$1 [L,QSA]
我应该注意,我已将此.htaccess文件放在根目录和/title/文件夹中。

不匹配
^title/(.+)$
您只需要匹配像这样的数字
^title/([\d]+)/?

否则,

www.domain.com/title/index.php?id=70048305
将匹配并重定向到:

index.php?id=index.php?id=70048305
试试这个

RewriteEngine On

RewriteRule ^([a-zA-Z0-9-+/]+)$ index.php?id=$1
RewriteRule ^([a-zA-Z0-9-+/]+)/$ index.php?id=$1

您正在本地主机上尝试吗?当我通常在本地主机上编辑
.htaccess
时,需要10-15分钟才能开始工作。有时甚至会在apache上重新启动。请注意,我回到这里来回答我自己的问题。第一个是有效的。
RewriteEngine On

RewriteRule ^([a-zA-Z0-9-+/]+)$ index.php?id=$1
RewriteRule ^([a-zA-Z0-9-+/]+)/$ index.php?id=$1