如何编辑.htaccess以同时允许rails和wordpress请求?

jak*_*tes 3 apache wordpress .htaccess ruby-on-rails

我想在我的rails应用程序中运行wordpress的实例。我目前在public / wordpress中拥有wordpress文件,但是我需要配置.htaccess文件以允许两种类型的请求。我怎么做?目前,.htaccess是:

Apache常规选项
AddHandler fcgid-script .fcgi RewriteRule上的
RewriteEngine
^ $ index.html [QSA]
RewriteRule ^([^。] +)/!$ $ 1.html [QSA]
RewriteCond%{REQUEST_FILENAME}!-f
RewriteRule ^(。 *)$ dispatch.fcgi [QSA,L]
ErrorDocument 500“应用程序错误应用程序无法正确启动”

str*_*xel 5

您应该首先将其添加到公用文件夹的.htaccess中:

RewriteCond %{REQUEST_URI} ^/wordpress.*
RewriteRule .* - [L]
Run Code Online (Sandbox Code Playgroud)

但是,这还不是全部。您还需要使用此添加项来编辑/ etc / apache2 / sites-available /(以告知Rails不要在应用程序的/ blog中处理任何内容):

<Location /wordpress>  
PassengerEnabled off
Run Code Online (Sandbox Code Playgroud)

同样在/etc/apache2/apache2.conf中,您可能需要告诉Apache使任何目录索引(例如wordpress /)执行index.php文件(如果存在):

DirectoryIndex index.php
Run Code Online (Sandbox Code Playgroud)