问题描述
我有Glassfish 3服务器,并且已经添加了,以便能够运行PHP应用程序在上面。一切都与它完美合作。现在我试图在我的服务器上运行应用程序。我能够打开应用程序,但它不允许我浏览页面,因为他们使用.htaccess文件来重写URL。我想知道如何在这种情况下重写URL?
以下是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
重写规则^ * $的index.php?QA -rewrite = $ 0&%{QUERY_STRING} [L]
您有任何解决方案吗?
使用Tuckey的(这受到并提供相似的功能)来实现重写规则。基本上,你必须:
- 获得Quercus的战争并解开它
- 下载并将其解压缩到Quercus中(这会将过滤器jar放在
WEB-INF / lib
以及WEB-INF
下的urlrewrite.xml
/ li>
- 在
web.xml中声明过滤器
(参见)。 - 将您的重写规则移植到
urlrewrite.xml
file。 - 重新打包并部署战争(或将其部署为展开式存档)。
Glassfish上的交讨论了这种方法。适应您的需求。
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?
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 theurlrewrite.xml
underWEB-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.
这篇关于用Quercus的PHP重写Glassfish上的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!