如何通过.htacess将目录名隐藏到最终用户(How can I hide the directory name to the end user via .htacess)

编程入门 行业动态 更新时间:2024-10-22 14:37:30
如何通过.htacess将目录名隐藏到最终用户(How can I hide the directory name to the end user via .htacess)

我怎样才能建立这个链接

http(with or without s)://(with or without www).puaction.com/articles/Top-7-Best-Pheromone-Colognes-for-Men

看起来像这样:

https://puaction.com/Top-7-Best-Pheromone-Colognes-for-Men

文章目录中的每个文件夹都会显示没有文章目录所以......

http(with or without s)://(with or without www).puaction.com/articles/(any article)

将是(非www / https /文章目录将不会由最终用户显示)

https://puaction.com/ {any article name}

How can I make this link(s)

http(with or without s)://(with or without www).puaction.com/articles/Top-7-Best-Pheromone-Colognes-for-Men

looks like this :

https://puaction.com/Top-7-Best-Pheromone-Colognes-for-Men

each folder inside articles directory will displayed without the article directory so...

http(with or without s)://(with or without www).puaction.com/articles/(any article)

will be (non www / https / article directory will not be displayed by the end user)

https://puaction.com/ {any article name}

最满意答案

您可以在root .htaccess中使用此代码:

RewriteEngine On RewriteCond %{THE_REQUEST} \s/+articles/([\S+) [NC] RewriteRule ^ https://puaction.com/%1? [R=301,L,NE] RewriteRule ^([^/.]+)/?$ /articles/$1 [L]

You can use this code in root .htaccess:

RewriteEngine On RewriteCond %{THE_REQUEST} \s/+articles/([\S+) [NC] RewriteRule ^ https://puaction.com/%1? [R=301,L,NE] RewriteRule ^([^/.]+)/?$ /articles/$1 [L]

更多推荐

本文发布于:2023-08-04 05:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1409392.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最终用户   目录   htacess   user   directory

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!