Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 MVC 并处理路由器,并且正在努力应用重定向。
请求:site.com/christmas 重定向:site.com/holiday/christmas
不认为我应该保持“控制器圣诞节”来进行重定向 我的疑问是我应该在什么阶段执行重定向? 我使用单独配置重定向的特殊情况创建配置?
谢谢
这个重写规则可能会帮助你..
这会重写到达的每个site.com/(anything)请求site.com/holiday/(anything):
site.com/(anything)
site.com/holiday/(anything)
RewriteEngine on RewriteRule ^([a-zA-Z]+)/?$ /holiday/$1
只需将它放在您的 .htaccess 中,它就可以完成它的工作。
如果您只想site.com/christmas重定向 ,请尝试以下操作:
site.com/christmas
RewriteRule ^christmas/?$ /holiday/christmas