Regex .htaccess URL重写(从URL中删除文件夹)
正在尝试在我们的网站上为我们显示Regex .htaccess URL重写(从URL中删除文件夹),regex,apache,.htaccess,mod-rewrite,subdirectory,Regex,Apache,.htaccess,Mod Rewrite,Subdirectory,正在尝试在我们的网站上为我们显示隔离区.country/coronavirus/dashboard/usa/而不是隔离区.country/coronavirus/dashboard/region/usa/,使用的是: Options+FollowSymLinks-多视图 #打开mod_rewrite 重新启动发动机 重写数据库/冠状病毒/仪表板/ 重写规则^region/(.*)$/$1[L,NC,R] 请让我知道为什么上面的解决方案似乎没有预期的重写。谢谢大家! 您可以在/coronavi
隔离区.country/coronavirus/dashboard/usa/
而不是隔离区.country/coronavirus/dashboard/region/usa/
,使用的是:
Options+FollowSymLinks-多视图
#打开mod_rewrite
重新启动发动机
重写数据库/冠状病毒/仪表板/
重写规则^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/
您可以在/coronavirus/dashboard/.htaccess
中使用这些规则:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /coronavirus/dashboard/
RewriteRule ^(?!region/).*$ region/$0 [L,NC]
这将允许您将URL用作:
https://quarantine.country/coronavirus/dashboard/usa/
我有我的URLhttps://www.test.com/something/en/home
。这里我的代码在目录中,但我需要从URL中删除它。所以URL应该是https://www.test.com/en/home
。我用RewriteBase/
尝试了上述规则,但它不起作用@anubhava请打开一个新问题,这样我可能会更好地理解它以帮助您解决问题我有我的URLhttps://www.test.com/something/en/home
。这里我的代码在目录中,但我需要从URL中删除它。所以URL应该是https://www.test.com/en/home
。我用RewriteBase/
尝试了上述规则,但它不起作用@anubhava请打开一个新问题,这样我可能会更好地理解它,以帮助您解决问题我有类似https://www.test.com/something/en/home
。这里我的代码在目录中,但我需要从URL中删除它。所以URL应该是https://www.test.com/en/home
。我用RewriteBase/
尝试了上述规则,但它不起作用@yatkoI我的URL像https://www.test.com/something/en/home
。这里我的代码在目录中,但我需要从URL中删除它。所以URL应该是https://www.test.com/en/home
。我用RewriteBase/
尝试了上述规则,但@yatko不起作用