2010-07-09 27 views
2

我有Glassfish 3服務器,並增加了Quercus 4.0.7以便能夠在其上運行PHP應用程序。一切都與它完美合作。現在我試圖在我的服務器上運行Question2Answer應用程序。我能夠打開應用程序,但它不允許我瀏覽頁面,因爲他們使用.htaccess文件來重寫URL。我想知道如何在這種情況下重寫URL?用Quercus重寫Glassfish上的URL PHP

這裏是Question2Answer的.htaccess內部有:

DirectoryIndex index.php 
RewriteEngine On 
#RewriteBase /your-sub-directory 
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$ 
RewriteRule . %1/%2 [R=301,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L] 

你有任何的解決方案?

+0

有趣的是,有人在你的幾個小時後發佈了幾乎[相同的問題](http://stackoverflow.com/questions/3216973/urlrewritefilter-with-glassfish/)。我想我要把另一個標記爲重複。 – 2010-07-10 00:15:31

回答

3

使用Tuckey的UrlRewriteFilter(其靈感來自於mod_rewrite並提供了類似的功能)來實現重寫規則。基本上,你必須:

  • 獲取遼東的戰爭和解壓
  • 下載the filter並解壓裏面櫟(這將會把過濾罐內WEB-INF/liburlrewrite.xmlWEB-INF)。
  • 聲明web.xml中的過濾器(請參閱install instructions)。
  • 將您的重寫規則「端口」到urlrewrite.xml文件。
  • 重新打包並部署戰爭(或將其部署爲爆炸存檔)。

該帖子Drupal on Glassfish with clean urls using Url Rewrite Filter討論了這種方法。適應您的需求。