[英]Rewrite all folder and files with htaccess
I want all files and folder links change我希望更改所有文件和文件夹链接
I use below code for this problem, but not work我使用以下代码解决此问题,但不起作用
RewriteEngine on
RewriteRule ^([^/]+)(\.zip|\.pdf|\.jpg|\.png)$ index.php?file=$1$2 [NC,L]
I want change actual url to another url automatic我想将实际 url 自动更改为另一个 url
upload/1.png => index.php?file=/upload/1.png
upload/in/2.png => index.php?file=/upload/in/1.png
You may use these rules in your site root .htaccess:您可以在站点根目录 .htaccess 中使用这些规则:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php\?file=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=301,L,NE]
RewriteRule ^[\w-]+\.(?:zip|pdf|jpe?g|png)$ index.php?file=$0 [L,QSA,NC]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.