。htaccess URL重写(从URL删除文件夹)

问题描述 投票:0回答:1

尝试使用quarantine.country/coronavirus/dashboard/usa/quarantine.country/coronavirus/dashboard/region/usa/在美国的covid-19 dashboard上显示@anubhava而不是solution

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /coronavirus/dashboard/

RewriteRule ^region/(.*)$ /$1 [L,NC,R]
  • 请让我知道为什么上述解决方案似乎具有所需的重写。谢谢!
apache .htaccess redirect url-rewriting subdirectory
1个回答
0
投票

您可以在/coronavirus/dashboard/.htaccess中使用这些规则:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /coronavirus/dashboard/

RewriteRule ^(?!region/).*$ region/$0 [L,NC]

这将使您将URL用作:https://quarantine.country/coronavirus/dashboard/usa/

© www.soinside.com 2019 - 2024. All rights reserved.