Mod rewrite mod_rewrite将一些请求定向到新目录

Mod rewrite mod_rewrite将一些请求定向到新目录,mod-rewrite,Mod Rewrite,我有一个网站,前端和后端都通过index.php运行。要访问后端,请转到。这仍将通过index.php运行,但随后连接到数据库并转到正确的目录。后端管理在站点上收集的捐赠信息 我想将前端更改为WordPress,但仍然在原始数据库中收集捐赠信息,并从后端查看 与其重写所有代码,我想知道是否有一种方法可以使用mod rewrite并将WordPress文件放在一个单独的目录中。这样,任何以/Admin作为起始的请求都将通过原始index.php,而任何其他请求都将通过WordPress重定向到目录

我有一个网站,前端和后端都通过index.php运行。要访问后端,请转到。这仍将通过index.php运行,但随后连接到数据库并转到正确的目录。后端管理在站点上收集的捐赠信息

我想将前端更改为WordPress,但仍然在原始数据库中收集捐赠信息,并从后端查看

与其重写所有代码,我想知道是否有一种方法可以使用mod rewrite并将WordPress文件放在一个单独的目录中。这样,任何以/Admin作为起始的请求都将通过原始index.php,而任何其他请求都将通过WordPress重定向到目录

我最初试过:

RewriteCond %{REQUEST_URI} !^/Admin
RewriteRule ^(.*)$ gpf/$1 [L]
但是请求/Admin只会给我一个404错误

提前感谢您的帮助

这是完整的.htaccess文件

RewriteEngine On
Options -Indexes

# Serve 'gate' as php
<Files gate>
    SetHandler application/x-httpd-php
    AcceptPathInfo On
</Files>

FileETag MTime Size
AddCharset UTF-8 .xml

AddType video/mp4  mp4 m4v
AddType audio/mp4  m4a
AddType video/ogg  ogv
AddType audio/ogg  ogg oga
AddType video/webm webm

# redirect all domains (.net, .com, .biz, etc) to .org
RewriteCond %{HTTP_HOST} !^www\.mysite\.org$ [NC]
RewriteRule ^(.*)$ http://www.mysite.org/$1 [R=301,L]

# Route search
RewriteRule ^search$ /search/ [R,NC,L]

RewriteCond %{REQUEST_URI} !^/Admin
RewriteRule ^(.*)$ gpf/$1 [L]

# Route domain plus slash correctly
RewriteRule  ^$ /gate/ [L]

# All requests: serve _gate_ as php. 1st arg is requested URL qs preserved
RewriteRule ^([0-9A-Z].*) /gate/$1 [QSA,L]
RewriteRule ^rss\.xml /gate/rss.xml [QSA,L]

# PHP directives - should comment out on production server
php_value display_errors 1
php_value display_startup_errors 1

AddOutputFilterByType DEFLATE text/html application/x-javascript text/css text/javascript text/plain


<IfModule mod_expires.c>
ExpiresActive On

# Manually change filenames for static images. CMS changes names in dyn
ExpiresByType image/gif "access plus 9 months"
ExpiresByType image/jpg "access plus 9 months"
ExpiresByType image/jpeg "access plus 9 months"
ExpiresByType image/png "access plus 9 months"

# Rare changes. manually change filename

ExpiresByType image/x-icon "access plus 9 months"
ExpiresByType image/vnd.microsoft.icon "access plus 9 months"

# PDFs should never change. CMS renames in dyn
ExpiresByType application/pdf "access plus 6 months"
ExpiresByType application/x-pdf "access plus 6 months"

# Frequent changes. ASFU dynamic rename
ExpiresByType text/css "access plus 6 months"
ExpiresByType text/javascript "access plus 6 months"
ExpiresByType application/x-javascript "access plus 6 months"
</IfModule>
重新编写引擎打开
选项-索引
#将“门”用作php
SetHandler应用程序/x-httpd-php
上的AcceptPathInfo
FileTag MTime大小
AddCharset UTF-8.xml
AddType视频/mp4 mp4 m4v
AddType音频/mp4 m4a
AddType视频/ogg ogv
AddType音频/ogg ogg oga
AddType视频/webm webm
#将所有域(.net、.com、.biz等)重定向到.org
重写cond%{HTTP_HOST}^www\.mysite\.org$[NC]
重写规则^(.*)$http://www.mysite.org/$1[R=301,L]
#路线搜索
重写规则^search$/search/[R,NC,L]
重写cond%{REQUEST_URI}^/管理
重写规则^(.*)$gpf/$1[L]
#正确路由域加斜杠
重写规则^$/gate/[L]
#所有请求:作为php服务。请求的第一个参数URL qs已保留
重写规则^([0-9A-Z].*)/gate/$1[QSA,L]
重写规则^rss\.xml/gate/rss.xml[QSA,L]
#PHP指令-应该在生产服务器上注释掉
php_值显示_错误1
php\u值显示\u启动\u错误1
AddOutputFilterByType DEFLATE text/html应用程序/x-javascript text/css text/javascript text/plain
过期于
#手动更改静态图像的文件名。CMS在dyn中更改名称
ExpiresByType image/gif“访问加9个月”
ExpiresByType图像/jpg“访问加9个月”
过期按类型图像/jpeg“访问加9个月”
ExpiresByType image/png“访问加9个月”
#罕见的变化。手动更改文件名
ExpiresByType图像/x图标“访问加9个月”
ExpiresByType image/vnd.microsoft.icon“访问加9个月”
#PDF永远不应该改变。CMS在dyn中重命名
过期按类型应用程序/pdf“访问加6个月”
过期按类型应用程序/x-pdf“访问加6个月”
#频繁的变化。ASFU动态重命名
ExpiresByType文本/css“访问加6个月”
ExpiresByType文本/javascript“访问加6个月”
ExpiresByType应用程序/x-javascript“访问加6个月”

尝试添加其他条件:

RewriteCond %{REQUEST_URI} !^/Admin
RewriteCond %{REQUEST_URI} !^/gate
RewriteRule ^(.*)$ /gpf/$1 [L]

并在所有
/gate/
规则之后移动规则。

您的其他规则在哪里/什么地方?非常感谢。添加附加条件成功了。我需要在/gate/rules之前保存它,否则前端页面的请求也会通过gate。