【发布时间】:2018-07-04 22:45:37
【问题描述】:
我正在尝试执行以下操作...
需要重写、重命名或重定向的原始路径:
http://www.example.com/_plugin/notifications/
收件人:
http://www.example.com/notifications/
通过根 htaccess 文件...任何帮助将不胜感激!
================================================ ===================
这不起作用:
RewriteEngine On
RewriteRule ^/_plugin/notifications$ /notifications [L]
这也不起作用:
RewriteEngine On
RedirectMatch ^/_plugin/notifications$ /notifications/
这也不起作用:
RewriteEngine On
RewriteRule ^notifications/(.*)$ /notifications$1 [R=301,NC,L]
==============================
编辑
在 @Starkeen 的帮助下 - 我对此有一些后续问题。
- 有没有办法缩短 .htaccess 文件,但如果可以说我 文件夹中有多个子文件夹,而不是写那个 1 每个子文件夹的条件和 2 条规则?
- 如何让子文件夹的子文件夹显示?目前它正在向我抛出 404... :(
============
在后续问题 #1 上仍然需要帮助,但我相信我收到了问题 #2。
后续问题 #2 的解决方案(我相信):
RewriteCond %{THE_REQUEST} /_plugin/notifications/ [NC]
RewriteRule ^_plugin/notifications/(.*)$ /notifications/$1 [L,R]
RewriteRule ^notifications/(.*)$ /_plugin/notifications/$1 [L]
【问题讨论】:
标签: .htaccess redirect mod-rewrite url-rewriting rename