将链接类型从.php?id =更改为html

问题描述 投票:1回答:1

我有一个托管和共享PHP脚本的文件,它使用基本类型的链接,当文件上传时,文件的基本链接将是:http://example.com/do.php?id=1

注意到(1)是文件ID。

现在该脚本有一个功能,可以使用HTML链接类型启用mod重写..当激活它时..上面的链接将是这样的:http://example.com/download1.html

现在,需要编辑htaccess文件以将链接更改为另一个形状..所以我想要做的是使上面的链接看起来像:http://example.com/filename_FileID.htmlhttp://example.com/FileID.htmlhttp://example.com/filename_RandomCharectars&numbers.html

我不知道怎么做..请帮我编辑我的htaccess ..

这是正确的htaccess文件:

RewriteRule ^download([0-9]*).html$ do.php?id=$1
RewriteRule ^downloadf-(.*)-([a-zA-Z0-9_-]*).html$ do.php?filename=$1&x=$2
RewriteRule ^down-([0-9]*).html$ do.php?down=$1
RewriteRule ^downf-(.*)-([a-zA-Z0-9_-]*).html$ do.php?downf=$1&x=$2
RewriteRule ^downex-([0-9]*).html$ do.php?down=$1
RewriteRule ^downexf-(.*)-([a-zA-Z0-9_-]*).html$ do.php?downexf=$1&x=$2
php apache .htaccess webserver httpd.conf
1个回答
0
投票

对于http://example.com/FileID.html(我假设“FileID”将是一个数值)

规则是

RewriteRule ^([0-9]*)\.html$ do.php?id=$1

对于http://example.com/filename_FileID.html规则是

RewriteRule ^filename_([0-9]*)\.html$ do.php?id=$1

对于http://example.com/filename_RandomCharectars&numbers.html规则是

RewriteRule ^filename_(.*)\.html$ do.php?id=$1
© www.soinside.com 2019 - 2024. All rights reserved.