簡體   English   中英

將htaccess重寫規則移植到hiphop-php配置

[英]Porting htaccess rewrite rules to hiphop-php config

我有一個CodeIgniter項目,需要重寫規則來導航控制器/視圖等。 我已經在Ubuntu 12.04上正確安裝了hiphop-php,它運行得很好,包括在他們的網站上提供的示例WordPress安裝和重寫規則。

但是,我需要找出適用於CodeIgniter index.php / controller設置的正確重寫規則,我自己也沒有多少運氣。

這是一個用於WP重寫的示例hiphop-php配置文件:

http://www.hiphop-php.com/wp/

VirtualHost {
  * {
    Pattern = .*
    RewriteRules {
      dirindex {
        pattern = ^/(.*)/$
        to = $1/index.php
        qsa = true
      }
    }
  }
}

StaticFile {
  FilesMatch {
    * {
      pattern = .*\.(dll|exe)
      headers {
        * = Content-Disposition: attachment
      }
    }
  }

這是Apache的CodeIgniter mod_rewrite示例:

http://www.farinspace.com/codeigniter-htaccess-file/

<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /

    ### Canonicalize codeigniter URLs

    # If your default controller is something other than
    # "welcome" you should probably change this
    RewriteRule ^(welcome(/index)?|index(\.php)?)/?$ / [L,R=301]
    RewriteRule ^(.*)/index/?$ $1 [L,R=301]

    # Removes trailing slashes (prevents SEO duplicate content issues)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)/$ $1 [L,R=301]

    ###

    # Removes access to the system folder by users.
    # Additionally this will allow you to create a System.php controller,
    # previously this would not have been possible.
    # 'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    # Checks to see if the user is attempting to access a valid file,
    # such as an image or css document, if this isn't true it sends the
    # request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>

基本上我需要重寫的是使用CodeIgniter的index.php控制器正確地路由請求,這似乎是apache重寫規則的最后一部分。 其余的我可以在看到一些例子后一起破解。

謝謝你!

通常情況下,我通過自學來解決這個問題,並且有些人從Trip的答案中推進了正確的方向。 我寫了如何使用nginx作為代理以及如何通過nginx推送PHP請求。

http://www.kyleboddy.com/2013/05/02/facebooks-hiphop-engine-when-to-use-it-and-getting-it-to-work-with-codeigniter/

我沒有足夠的聲譽對SO發表評論,但......

https://github.com/facebook/hiphop-php/blob/master/hphp/doc/options.compiled

看起來沒有辦法在HHPHP配置中復制-d或-f標志,但選項的文檔並不完全徹底。 如果可能,它必須看起來像這樣:

    * {
      pattern = ^(.*)$
      to = /path/to/codeigniter/index.php/$1
      qsa = true
      conditions {
        -d {
          pattern = %{REQUEST_FILENAME}
          type = request
          negate = true
        }
        -f {
          pattern = %{REQUEST_FILENAME}
          type = request
          negate = true
        }
      }
    }

你沿着這些方向嘗試了什么嗎? 編輯:也許用%{REQUEST_FILENAME}塊交換-d和-f文件標志。 我可以倒退了。 再次,文檔不是很有啟發性,我只是吐痰。

使用NGINX作為hiphop php的前端。 作為一個優點,您可以獲得更好的服務靜態文件性能。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM