.htaccess URL重写(从URL删除文件夹) [英] .htaccess URL rewrite (remove folder from URL)

查看:92
本文介绍了.htaccess URL重写(从URL删除文件夹)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试显示 quarantine.country/coronavirus/dashboard/usa / 而不是 quarantine.country/coronavirus/dashboard/region/usa/ 在我们的 covid-19仪表板中,使用< a href = https://stackoverflow.com/users/548225/anubhava> @anubhava 的解决方案

Trying to show quarantine.country/coronavirus/dashboard/usa/ instead of quarantine.country/coronavirus/dashboard/region/usa/ at our covid-19 dashboard for US, using @anubhava's solution:

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

RewriteRule ^region/(.*)$ /$1 [L,NC,R]




  • 请让我知道上面的解决方案为什么没有似乎具有所需的重写。谢谢!

  • 推荐答案

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

    Options +FollowSymLinks -MultiViews
    RewriteEngine On
    RewriteBase /coronavirus/dashboard/
    
    RewriteRule ^(?!region/).*$ region/$0 [L,NC]
    

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

    This will let you use URL as: https://quarantine.country/coronavirus/dashboard/usa/

    这篇关于.htaccess URL重写(从URL删除文件夹)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆