Php 重定向后访问旧站点
我需要做永久重定向从客户旧网站到新的,重定向是从hissite.eu到newsite.com,相同的主机,但其他域。现在,他仍然想通过一些子域访问他的旧站点,如果我能让它工作的话,这不会是问题,但是旧站点的定制CMS做得很糟糕,很多硬编码,如果我把它移动到任何目录,它就是不工作 所以,我的问题是,如果我从oldsite.eu重定向到newsite.com,我如何为他提供访问旧站点的权限?如果他输入的是ip地址而不是域,是否有可能不重定向,但我想管理面板也不会工作。除了特定的ip之外,是否可以对每个人进行重定向 使用当前htaccess更新:Php 重定向后访问旧站点,php,.htaccess,redirect,url-redirection,server-administration,Php,.htaccess,Redirect,Url Redirection,Server Administration,我需要做永久重定向从客户旧网站到新的,重定向是从hissite.eu到newsite.com,相同的主机,但其他域。现在,他仍然想通过一些子域访问他的旧站点,如果我能让它工作的话,这不会是问题,但是旧站点的定制CMS做得很糟糕,很多硬编码,如果我把它移动到任何目录,它就是不工作 所以,我的问题是,如果我从oldsite.eu重定向到newsite.com,我如何为他提供访问旧站点的权限?如果他输入的是ip地址而不是域,是否有可能不重定向,但我想管理面板也不会工作。除了特定的ip之外,是否可以对每
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
Rewriterule ^index$ index.php [L]
Rewriterule ^login$ login.php [L]
Rewriterule ^register$ register.php [L]
Rewriterule ^classified_new$ classified_new.php [L]
Rewriterule ^account_classifieds$ account_classifieds.php [L]
Rewriterule ^account_classifieds_manage$ account_classifieds_manage.php [L]
Rewriterule ^account_confirm$ account_confirm.php [L]
Rewriterule ^account_details$ account_details.php [L]
Rewriterule ^account_invoice_browse$ account_invoice_browse.php [L]
Rewriterule ^account_invoice_details$ account_invoice_details.php [L]
Rewriterule ^account_main$ account_main.php [L]
Rewriterule ^account_messages$ account_messages.php [L]
Rewriterule ^account_profile$ account_profile.php [L]
Rewriterule ^ajax_request$ ajax_request.php [L]
Rewriterule ^classified_browse$ classified_browse.php [L]
Rewriterule ^classified_details$ classified_details.php [L]
Rewriterule ^classified_new_form$ classified_new_form.php [L]
Rewriterule ^classified_new_premium$ classified_new_premium.php [L]
Rewriterule ^classified_payment$ classified_payment.php [L]
Rewriterule ^classified_new_confirmation$ classified_new_confirmation.php [L]
Rewriterule ^classified_payment_process$ classified_payment_process.php [L]
Rewriterule ^classified_payment_response$ classified_payment_response.php [L]
Rewriterule ^classifieds_json$ classifieds_json.php [L]
Rewriterule ^convert$ convert.php [L]
Rewriterule ^help$ help.php [L]
Rewriterule ^login_process$ login_process.php [L]
Rewriterule ^search_advanced$ search_advanced.php [L]
Rewriterule ^verification_image$ verification_image.php [L]
#search result
Rewriterule ^search/(.*)$ search_results.php?q=$1 [L]
#classified detail
Rewriterule ^classified/(.*)$ classified_details.php?id=$1 [L]
</IfModule>
重新启动发动机
重写cond%{HTTP_HOST}^www\。
重写规则^(.*)$https://www.%{HTTP_HOST}/$1[R=301,L]
重写cond%{HTTPS}=关于[NC]
重写规则^.*$https://%{SERVER_NAME}%{REQUEST_URI}[R,L]
重写规则^index$index.php[L]
重写规则^login$login.php[L]
重写规则^register$register.php[L]
重写规则^classified\u new$classified\u new.php[L]
重写规则^account\u classifieds$account\u classifieds.php[L]
重写规则^account\u classifieds\u manage$account\u classifieds\u manage.php[L]
重写规则^account\u confirm$account\u confirm.php[L]
重写规则^account\u details$account\u details.php[L]
重写规则^account\u invoice\u browse$account\u invoice\u browse.php[L]
重写规则^account\u invoice\u details$account\u invoice\u details.php[L]
重写规则^account\u main$account\u main.php[L]
重写规则^account\u messages$account\u messages.php[L]
重写规则^account\u profile$account\u profile.php[L]
重写规则^ajax\u request$ajax\u request.php[L]
重写规则^classified\u browse$classified\u browse.php[L]
重写规则^classified\u details$classified\u details.php[L]
重写规则^classified\u new\u form$classified\u new\u form.php[L]
重写规则^classified\u new\u premium$classified\u new\u premium.php[L]
重写规则^classified_payment$classified_payment.php[L]
重写规则^classified\u new\u confirmation$classified\u new\u confirmation.php[L]
重写规则^classified\u payment\u process$classified\u payment\u process.php[L]
重写规则^classified\u payment\u response$classified\u payment\u response.php[L]
重写规则^classifieds\u json$classifieds\u json.php[L]
重写规则^convert$convert.php[L]
重写规则^help$help.php[L]
重写规则^login\u process$login\u process.php[L]
重写规则^search\u advanced$search\u advanced.php[L]
重写规则^verification\u image$verification\u image.php[L]
#搜索结果
重写规则^search/(*)$search\u results.php?q=$1[L]
#机密细节
重写规则^classified/(*)$classified\u details.php?id=$1[L]
实现这一点的一个简单方法是通过客户机传递一个秘密查询参数(您可以根据需要使其更复杂)
编辑
查看您的.htaccess,我强烈建议您将多行
Rewriterule
合并。请参见下面的示例:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Rewriterule ^(index|login|register|help)$ $1.php [L,NC]
实现这一点的一个简单方法是通过客户机传递一个秘密查询参数(您可以根据需要使其更加复杂) 编辑
查看您的.htaccess,我强烈建议您将多行
Rewriterule
合并。请参见下面的示例:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Rewriterule ^(index|login|register|help)$ $1.php [L,NC]
可以重定向除给定IP之外的所有IP,您可以向重定向添加条件,例如:
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteCond %{REMOTE_ADDR} !^xxx\.xxx\.xxx\.xxx$
RewriteRule ^ http://newdomain.com%{REQUEST_URI} [R=301,L]
对于多个IP:
RewriteCond %{REMOTE_ADDR} !^xxx\.xxx\.xxx\.xxx$
RewriteCond %{REMOTE_ADDR} !^xxx\.xxx\.xxx\.xxx$
RewriteCond %{REMOTE_ADDR} !^xxx\.xxx\.xxx\.xxx$
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^ http://newdomain.com%{REQUEST_URI} [R=301,L]
或者如果IP具有相同的块192.168.0.1、192.168.0.2、192.168.0.3:
RewriteCond %{REMOTE_ADDR} !^xxx\.xxx\.xxx\.
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^ http://newdomain.com%{REQUEST_URI} [R=301,L]
将xxx\.xxx\.xxx\.xxx
更改为您的客户端IP
但是,这会给您带来一些问题,例如:
可能还有更多,但这是最常见的。可以重定向除给定IP之外的所有IP,您可以在重定向中添加一个条件,例如:
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteCond %{REMOTE_ADDR} !^xxx\.xxx\.xxx\.xxx$
RewriteRule ^ http://newdomain.com%{REQUEST_URI} [R=301,L]
对于多个IP:
RewriteCond %{REMOTE_ADDR} !^xxx\.xxx\.xxx\.xxx$
RewriteCond %{REMOTE_ADDR} !^xxx\.xxx\.xxx\.xxx$
RewriteCond %{REMOTE_ADDR} !^xxx\.xxx\.xxx\.xxx$
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^ http://newdomain.com%{REQUEST_URI} [R=301,L]
或者如果IP具有相同的块192.168.0.1、192.168.0.2、192.168.0.3:
RewriteCond %{REMOTE_ADDR} !^xxx\.xxx\.xxx\.
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^ http://newdomain.com%{REQUEST_URI} [R=301,L]
将xxx\.xxx\.xxx\.xxx
更改为您的客户端IP
但是,这会给您带来一些问题,例如: