.htaccess将url重写为索引,并在文件夹斜杠后获得urldata


.htaccess rewrite url to index and get urldata after folder slash

首先,我想展示一个完整的工作示例,它几乎满足了我的要求:

. htaccess

RewriteEngine On
RewriteRule ^index.php/(.*)$ index.php?title=$1

index . php

echo 'title = '.$_GET['title'];

请求localhost/php/htaccess2/index . php/测试

RESULT title = test


现在我希望它工作通过请求localhost/php/htaccess2/test

所以我把。htaccess改成了
RewriteEngine On
RewriteRule (.*) index.php?title=$1

然后返回

RESULT title = index.php

我想让它返回title = test

请帮帮我!


我用另一个旗帜如QSA解决了它http://httpd.apache.org/docs/current/rewrite/flags.html

你试过了吗?

RewriteRule (.*) index.php?title=$1 [NC]

:

RewriteRule ^(.*)$ index.php?title=$1 [PT,L]