从子文件夹重定向到主文件夹,将多个页面重定向到一个页面

时间:2016-10-07 08:04:08

标签: regex apache .htaccess redirect mod-rewrite

我们有一个新网站,内置WordPress。它将取代旧网站,该网站建立在自定义CMS上。

旧网站正在使用此结构> domain.nl/content/page-title适用于大多数内容页面。在新网站上,我们将使用domain.nl/page-title。 我们还将几个非常短的内容页面组合成1。 domain.nl/pageaboutsubject1和domain.nl/pageaboutsubject2现在位于domain.nl/pageboutboth

我可以使用以下方法解决文件夹的问题:

RewriteEngine on
RewriteRule ^content/(.*)$ /$1 [R=301,L]

这将使所有网址在主文件夹和网页标题之间没有/ content /重定向。

但现在我仍然坚持将其他页面重定向到新的页面。 我读了一些关于' L'在[R = 301,L]中防止进一步的重定向,所以我试图删除它。但没有运气。 添加:

RewriteRule ^content/subject1 /subjectboth [R=301]

无效,并且:

RewriteRule ^/subject1 /subjectboth [R=301]

也行不通。

1 个答案:

答案 0 :(得分:1)

问题似乎出现在你的reegx中,以便匹配第二条规则。

这应该适合你:

import UIKit
class oneViewController: RootViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        RootViewController.amIaccessible = true // I have initialized this variable of RootViewController 
    }
}

import UIKit
class twoViewController: RootViewController {
    var amIaccessible: Bool = false

    override func viewDidLoad() {
        super.viewDidLoad()
        print(RootViewController.amIaccessible) // it is printing true now
    }
}

参考文献:

相关问题