.htaccess URL 重写(从 URL 中删除文件夹)
.htaccess URL rewrite (remove folder from URL)
试图在我们的 covid-19 dashboard for US, using @anubhava's solution 中显示 quarantine.country/coronavirus/dashboard/usa/
而不是 quarantine.country/coronavirus/dashboard/region/usa/
:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /coronavirus/dashboard/
RewriteRule ^region/(.*)$ / [L,NC,R]
- 请告诉我为什么上面的解决方案似乎没有所需的重写。谢谢!
您可以在 /coronavirus/dashboard/.htaccess
中使用这些规则:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /coronavirus/dashboard/
RewriteRule ^(?!region/).*$ region/[=10=] [L,NC]
这将使您可以将 URL 用作:
https://quarantine.country/coronavirus/dashboard/usa/
试图在我们的 covid-19 dashboard for US, using @anubhava's solution 中显示 quarantine.country/coronavirus/dashboard/usa/
而不是 quarantine.country/coronavirus/dashboard/region/usa/
:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /coronavirus/dashboard/
RewriteRule ^region/(.*)$ / [L,NC,R]
- 请告诉我为什么上面的解决方案似乎没有所需的重写。谢谢!
您可以在 /coronavirus/dashboard/.htaccess
中使用这些规则:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /coronavirus/dashboard/
RewriteRule ^(?!region/).*$ region/[=10=] [L,NC]
这将使您可以将 URL 用作:
https://quarantine.country/coronavirus/dashboard/usa/