[英]RewriteRule will not work in .htaccess file
I have found several questions on Stack that have show lots and lot of examples, but I have tried everyone in the book and this refuses to work. 我在Stack上发现了几个问题,这些问题展示了很多例子,但是我尝试了本书中的每个人,但是这拒绝了。
I am trying to convert. 我正在尝试转换。
www.domain.com/title/index.php?id=70048305
to 至
www.domain.com/title/70048305
I want it to be converted both ways. 我希望将其转换为两种方式。 When they type in with the query string and with the clean url. 当他们使用查询字符串和干净的URL键入时。
What is wrong with my rewrite? 我的重写有什么问题?
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^title/(.+)$ index.php?id=$1 [L,QSA]
I should note that I've placed this .htaccess file both on the root and in the /title/ folder. 我应该注意,我已经将此.htaccess文件放置在根目录和/ title /文件夹中。
Try this 尝试这个
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-+/]+)$ index.php?id=$1
RewriteRule ^([a-zA-Z0-9-+/]+)/$ index.php?id=$1
Don't match ^title/(.+)$
you need to be matching only numbers like so ^title/([\\d]+)/?
不匹配^title/(.+)$
您只需要匹配^title/([\\d]+)/?
Otherwise, 除此以外,
www.domain.com/title/index.php?id=70048305
will match and be redirected to: 将匹配并重定向到:
index.php?id=index.php?id=70048305
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.