.htaccess:重写url,一个变量到目录

时间:2018-02-07 11:30:49

标签: .htaccess url-rewriting

我想知道是否可以通过一些htaccess规则来实现最终结果。

config 文件夹中。其中*是要显示为文件夹的页面名称。

/projectdir/config/?p=* or /projectdir/config/index.php?p=*
to /projectdir/config/*/

实施例

/projectdir/config/?p=page1 => /projectdir/config/page1/
/projectdir/config/index.php?p=page1 => /projectdir/config/page1/

我尝试了this问题中发布的代码,但没有结果

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w\d~%.:_\-]+)$ index.php?p=$1 [NC]
  

基本上:http://localhost/index.php?page=controller

     

http://localhost/controller/

1 个答案:

答案 0 :(得分:1)

您可以在class ViewController: NSViewController { var dataToPass: String = "DataToPass" override func viewDidLoad() { super.viewDidLoad() } override func viewWillAppear() { performSegue(withIdentifier: NSStoryboardSegue.Identifier(rawValue: "segueIdentifier"), sender: self) } override func prepare(for segue: NSStoryboardSegue, sender: Any?) { if segue.identifier!.rawValue == "segueIdentifier" { let destinationViewController = segue.destinationController as! ViewController2 destinationViewController.dataToReceive = dataToPass } } } class ViewController2: NSViewController { var dataToReceive: String override func viewDidLoad() { super.viewDidLoad() } }

中使用此代码
/project/config/.htaccess