Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex .htaccess URL重写(从URL中删除文件夹)_Regex_Apache_.htaccess_Mod Rewrite_Subdirectory - Fatal编程技术网

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/

我有我的URL
https://www.test.com/something/en/home
。这里我的代码在目录
中,但我需要从URL中删除它。所以URL应该是
https://www.test.com/en/home
。我用
RewriteBase/
尝试了上述规则,但它不起作用@anubhava请打开一个新问题,这样我可能会更好地理解它以帮助您解决问题我有我的URL
https://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不起作用