如何通过.htaccess将目录名隐藏到最终用户

时间:2014-03-03 10:48:39

标签: .htaccess url https

如何建立此链接

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 / article目录)

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

1 个答案:

答案 0 :(得分:0)

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

RewriteEngine On

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

RewriteRule ^([^/.]+)/?$ /articles/$1 [L]