【问题标题】:How do I edit .htaccess to allow both rails and wordpress requests?如何编辑 .htaccess 以允许 rails 和 wordpress 请求?
【发布时间】:2011-02-12 06:22:53
【问题描述】:
我想在我的 rails 应用程序中运行一个 wordpress 实例。我目前将 wordpress 文件存放在 public/wordpress 中,但我需要配置我的 .htaccess 文件以允许这两种类型的请求。我怎么做?目前,.htaccess 是:
常规 Apache 选项
AddHandler fcgid-script .fcgi
重写引擎开启
RewriteRule ^$ index.html [QSA]
重写规则 ^([^.]+)/!$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
ErrorDocument 500 "应用程序错误应用程序无法正常启动"
【问题讨论】:
标签:
ruby-on-rails
apache
wordpress
.htaccess
【解决方案1】:
您应该首先将其添加到公用文件夹中的 .htaccess 中:
RewriteCond %{REQUEST_URI} ^/wordpress.*
RewriteRule .* - [L]
然而,这还不是全部。您还需要编辑 /etc/apache2/sites-available/
加上这个(告诉 Rails 不要将 /blog 中的任何内容作为应用程序的一部分处理):
<Location /wordpress>
PassengerEnabled off
同样在 /etc/apache2/apache2.conf 中,您可能需要告诉 Apache 让任何目录索引(例如 wordpress/)执行 index.php 文件(如果有的话):
DirectoryIndex index.php