我有一个前端和后端都通过 index.php 运行的网站。要访问后端,您可以访问http://www.mysite.com/Admin。这仍将通过 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>