2
如何让这个我的页面重定向像一个网址:https://mysite/12345到https://mysite/image.php?id=12345缩短URL只包含获取请求?
我希望能够缩短的URL只包括GET请求。这可以通过php或.htaccess文件实现吗?
如何让这个我的页面重定向像一个网址:https://mysite/12345到https://mysite/image.php?id=12345缩短URL只包含获取请求?
我希望能够缩短的URL只包括GET请求。这可以通过php或.htaccess文件实现吗?
通常你会做这个使用.htaccess
文件,用条目是这样的: https://mysite/12345
为了走另外一条路,有一个:
RewriteEngine On
RewriteBase/
RewriteRule ^([0-9]+)(/?)$ image.php?id=$1 [NC,L]
所以,你可以在格式写你的网址url如https://mysite/image.php?id=12345
重定向到https://mysite/12345
RewriteCond %{THE_REQUEST} /(?:image\.php)?\?id=([^&\s]+) [NC]
RewriteRule^%1? [R=302,L,NE]