Rewrite URL on Glassfish with Quercus' PHP

自闭症网瘾萝莉.ら 提交于 2019-12-11 02:34:23

问题


I have Glassfish 3 server and have added Quercus 4.0.7 to to be able to run PHP applications on it. Everything works perfectly with it. Now I'm trying to run Question2Answer application on my server. I was able to open application but it's not allowing me to navigate from page to page because they are using .htaccess file to rewrite the URL. I was wondering how do we rewrite the URL in this case?

Here is what Question2Answer's .htaccess has inside:

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]

Do you have any solutions for that?


回答1:


Use Tuckey's UrlRewriteFilter (which is inspired by mod_rewrite and offers similar functionalities) to implement the rewrite rules. Basically, you'll have to:

  • Get Quercus's war and unpack it
  • Download the filter and unpack it inside Quercus (this will put the filter jar inside WEB-INF/lib and the urlrewrite.xml under WEB-INF).
  • Declare the filter in the web.xml (see the install instructions).
  • "Port" your rewrite rules to the urlrewrite.xml file.
  • Repackage and deploy the war (or deploy it as an exploded archive).

The post Drupal on Glassfish with clean urls using Url Rewrite Filter discusses this approach. Adapt it to your needs.



来源:https://stackoverflow.com/questions/3215723/rewrite-url-on-glassfish-with-quercus-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!