如何重定向链接中间带有%20的URL,然后在链接中附加目录

时间:2019-05-20 15:57:21

标签: html .htaccess url

我需要一个网址

/Fileshare%20Server/public/9d487a5a2681d0b89540ad1a0cadcd2e.php

并替换为

 /Fileshare%20Server/data/public/9d487a5a2681d0b89540ad1a0cadcd2e.php

但是当我尝试使用.htaccess文件重定向时,%20似乎是导致我出现问题的原因

我尝试过

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /Fileshare%20Server/data/$1

我现有的.htaccess文件是

<IfModule mod_rewrite.c>
# You must set the correct values here if you want
# to enable webDAV sharing. The values assume that your 
# ajaXplorer installation is at http://yourdomain/ajaxplorer 
# and that you want the webDAV shares to be accessible via 
# http://yourdomain/ajaxplorer/shares/repository_id/
RewriteEngine on
RewriteBase /ajaxplorer
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^shares ./dav.php [L]
RewriteRule ^api ./rest.php [L]

#Following lines seem to be necessary if PHP is working
#with apache as CGI or FCGI. Just remove the #
#See http://doc.tiki.org/WebDAV#Note_about_Apache_with_PHP_as_fcgi_or_cgi

#RewriteCond %{HTTP:Authorization} ^(.*)
#RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
</IfModule>

RewriteEngine开启 RewriteCond%{REQUEST_URI}!^ / public / RewriteRule ^(。*)$ / Fileshare%20Server / data / $ 1

当我打开链接

domain.com/Fileshare%20Server/public/9d487a5a2681d0b89540ad1a0cadcd2e.php

我希望它会转到

Fileshare%20Server/data/public/9d487a5a2681d0b89540ad1a0cadcd2e.php

但是我得到的只是一个损坏的链接

0 个答案:

没有答案