我有一个具有以下配置的Apache Web服务器
<VirtualHost *:80>
ServerName 111.111.111.111
ServerAlias hostname
# Following prevents hotlinking
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"
RewriteRule ^.*$ / [R,L]
...
...
...
</VirtualHost>我需要将所有后缀为/v1的请求重定向到不包含'v1‘后缀的相同路径。示例:从https://example.com/v1到https://example.com
我该如何实现?提前感谢
发布于 2018-04-19 19:18:29
我会用RedirectMatch这样做:
RedirectMatch ^/v1$ / [R,L]
RedirectMatch ^(.*)(/v1)$ $1 [R,L]因此,https://example.com/v1将导致https://example.com,例如,https://example.com/something/v1将被重定向到https://example.com/something
https://stackoverflow.com/questions/49798903
复制相似问题