从我们的网址中删除一个字词


Removing a word from our urls

我们的ftp帐户中有以下文件结构。

/index.php    
/views/account/users/index.php
/views/account/clients/index.php
/views/profile/index.php
/views/settings/index.php
....

这意味着网址如下:

www.thesite.com/
www.thesite.com/views/account/users/
www.thesite.com/views/account/clients/
www.thesite.com/views/profile/
www.thesite.com/views/settings/
...

我们需要的是从所有可能的变体中删除视图,以便我们可以链接到浏览器的地址栏中或在浏览器的地址栏中输入以下 URL。

 www.thesite.com/account/users/

任何帮助将不胜感激。

在您的网站根目录 .htaccess 中尝试以下规则:

RewriteEngine on
RewriteCond %{THE_REQUEST} 's/+views/('S*)'s [NC]
RewriteRule ^ /%1 [NE,L,R=302]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!views/).+)$ views/$1 [NC,L]

您可以在 Root/.htaccess 中使用以下规则:

RewriteEngine on

 #/foo to /views/foo
RewriteCond %{THE_REQUEST} /views/([^/.'s]+) [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteRule ^([^/.]+)/?$ /views/$1 [NC,L]
#Rewrite /foo/bar to /views/foo/bar
RewriteCond %{THE_REQUEST} /views/([^/]+)/([^/.'s]+) [NC]
RewriteRule ^ /%1/%2 [NC,L,R]
RewriteRule ^([^/]+)/([^/.]+)/?$ /views/$1/$2 [NC,