.htaccess htaccess文件以删除文件夹,并用破折号替换下划线
我需要更改以下url.htaccess htaccess文件以删除文件夹,并用破折号替换下划线,.htaccess,.htaccess,我需要更改以下url http://somedomain.com/news/a_sample_news_article.html 到 我的htaccess中有这个功能,它可以工作,但我相信它可以改进-有人有更好的解决方案吗 RewriteEngine on # replace underscores RewriteRule ^(news)/([^_]*)_+(.*)$ /$1/$2-$3 [L,NC,R=302] # redirect the directory from news to po
http://somedomain.com/news/a_sample_news_article.html
到
我的htaccess中有这个功能,它可以工作,但我相信它可以改进-有人有更好的解决方案吗
RewriteEngine on
# replace underscores
RewriteRule ^(news)/([^_]*)_+(.*)$ /$1/$2-$3 [L,NC,R=302]
# redirect the directory from news to post
RewriteRule ^news/(.*)$ /post/$1 [R,L]
# remove .html from end of url
RewriteRule ^(.*)\.html$ /$1 [L,R=301]
非常感谢任何帮助 重定向
- /新闻/美食酒吧
- /邮政/富吧
RewriteEngine on
# redirect "/news/foo_bar" to "/foo_bar"
RewriteRule ^news/(.+)$ /$1 [L,R]
#2 replace underscore with hypens
RewriteRule (.*)_(.*) $1-$2 [N,E=uscores:yes]
RewriteCond %{ENV:uscores} yes
RewriteRule ^(.+)$ /post/$1 [L,R]
重定向
- /新闻/美食酒吧
- /邮政/富吧
RewriteEngine on
# redirect "/news/foo_bar" to "/foo_bar"
RewriteRule ^news/(.+)$ /$1 [L,R]
#2 replace underscore with hypens
RewriteRule (.*)_(.*) $1-$2 [N,E=uscores:yes]
RewriteCond %{ENV:uscores} yes
RewriteRule ^(.+)$ /post/$1 [L,R]
非常感谢你回来-非常好。在这些规则的上下文中,从原始url中删除.html的最佳方法是什么?非常感谢您的回复-非常好。在这些规则的上下文中,从原始url中删除.html的最佳方法是什么?