-1

我想重定向我的示例网址,如下所示

https://example.com/r6KmjN
https://example.com/Q8w4d9
https://example.com/s8I2n2

结尾字符不会相同,而是 6 个字符

 https://example.com/tinyurl.php?id=r6KmjN
 https://example.com/tinyurl.php?id=Q8w4d9
 https://example.com/tinyurl.php?id=s8I2n2

这可能吗?如果您能帮助我解决这个问题,我们将不胜感激。谢谢

4

1 回答 1

1

在你的 /.htaccess 中试试这个:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ http://example.com/tinyurl.php?id=$1 [QSA,NC,L] 

如果要将其用于内部重定向,请从目标 url 中删除主机名和方案

于 2015-06-05T09:54:34.700 回答