简体   繁体   English

如何在.htaccess中修改此URL?

[英]How to modify this URL in .htaccess?

I want to modify URL with a check. 我想用支票修改URL。

  1. If there exists experiment as second folder, then do this 如果存在实验作为第二个文件夹,请执行此操作

    {site}.com/dashboard/experiment/closed/.../ {站点}的.com /仪表板/实验/关闭/.../

    to

    {site}.com/experiment/closed/.../ {站点}的.com /实验/关闭/.../

  2. If no experiment found in path, then don't do anything. 如果在路径中未找到实验,则不要执行任何操作。 For eg 例如

    {site}.com/dashboard/ex-view/closed/.../ {站点}的.com /仪表板/前视图/关闭/.../

How do I achive this using htaccess. 我如何使用htaccess实现这一点。 I'm using Laravel 5.1. 我正在使用Laravel 5.1。

This is what I tried but it doesn't meet the second condition. 这是我尝试过的,但不满足第二个条件。

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

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

You can try this rule in the .htaccess in the root. 您可以在根目录的.htaccess中尝试此规则。 The should only affect URL with experiment as the second folder. 只会影响以experiment作为第二个文件夹的URL。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM