我有一个网站,其前端和后端都通过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>
答案 0 :(得分:0)
尝试添加其他条件:
RewriteCond %{REQUEST_URI} !^/Admin
RewriteCond %{REQUEST_URI} !^/gate
RewriteRule ^(.*)$ /gpf/$1 [L]
在所有/gate/
规则之后移动规则。