使用 Quercus 重写 Glassfish 上的 URL PHP

发布于 2024-09-09 00:53:57 字数 697 浏览 6 评论 0原文

我有 Glassfish 3 服务器,并添加了 Quercus 4.0.7 以便能够在其上运行 PHP 应用程序。一切都与它完美配合。现在我尝试在我的服务器上运行 Question2Answer 应用程序。我能够打开应用程序,但它不允许我从一个页面导航到另一个页面,因为他们正在使用 .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
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]

您对此有什么解决方案吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相守太难 2024-09-16 00:53:57

使用 Tuckey 的 UrlRewriteFilter (其灵感来自 mod_rewrite 并提供类似的功能)来实现重写规则。基本上,您必须:

  • 获取 Quercus 的战争并解压它
  • 下载过滤器并解压它位于 Quercus 中(这会将过滤器 jar 放入 WEB-INF/lib 中,并将 urlrewrite.xml 放入 WEB-INF 中)。
  • web.xml 中声明过滤器(请参阅安装说明)。
  • 将您的重写规则“移植”到 urlrewrite.xml 文件中。
  • 重新打包并部署战争(或将其部署为分解存档)。

帖子 Drupal on Glassfish with clean urls using Url Rewrite Filter 讨论了这种方法。根据您的需求进行调整。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文