Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 使用htaccess从不同的HTML网站重定向到不同的Wordpress网站_Apache_.htaccess_Redirect_Mod Rewrite_Url Rewriting - Fatal编程技术网

Apache 使用htaccess从不同的HTML网站重定向到不同的Wordpress网站

Apache 使用htaccess从不同的HTML网站重定向到不同的Wordpress网站,apache,.htaccess,redirect,mod-rewrite,url-rewriting,Apache,.htaccess,Redirect,Mod Rewrite,Url Rewriting,我有一个HTML的网站,我有这个链接,我想重定向到 我的htaccess文件中有这个,但它不工作 <IfModule mod_rewrite.c> # Redirect non WordPress pages to corresponding post RewriteEngine On RewriteBase / RewriteRule ^/CA_NutritionIncentiveProgram/.htm$ https://wordpress-website.com/ca_nutr

我有一个HTML的网站,我有这个链接,我想重定向到

我的htaccess文件中有这个,但它不工作

<IfModule mod_rewrite.c>
# Redirect non WordPress pages to corresponding post
RewriteEngine On
RewriteBase /
RewriteRule ^/CA_NutritionIncentiveProgram/.htm$ https://wordpress-website.com/ca_nutritionincentiveprogram [R=301,L]
</IfModule>

#将非WordPress页面重定向到相应的帖子
重新启动发动机
重写基/
重写规则^/CA_NutritionIncentiveProgram/.htm$https://wordpress-website.com/ca_nutritionincentiveprogram [R=301,L]
当我加载这个HTML站点时,它会将我重定向到wordpress站点,但包含了.htm()

以下是我最近得到的信息(来源:RavinderSingh13)


重新启动发动机
RewriteCond%{HTTP_HOST}^html网站$[或]
重写cond%{HTTP_HOST}^www.html-website.com$
重写规则(.*)$http://www.wordpress-website.com.com/$1[R=301,L]
RewriteCond%{REQUEST_URI}^/(ca_nutritionincentiveprogram)/?$[NC]
RewriteCond%{REQUEST_FILENAME}.html-f
重写规则^(.*)http://%{http_HOST}%{REQUEST_URI}.html[NE,L]

如果您有任何帮助,请仅根据所显示的示例尝试以下内容。请确保在测试URL之前清除浏览器的缓存。此外,您不需要将
R=301
放在浏览器中,否则它会将浏览器中的URL重写为新的URL(我们显然不想向用户显示)


请您仅根据所展示的样品,尝试以下内容。请确保在测试URL之前清除浏览器的缓存。此外,您不需要将
R=301
放在浏览器中,否则它会将浏览器中的URL重写为新的URL(我们显然不想向用户显示)


您的原始规则很好,如果在
server.config
上下文中使用,应该可以正常工作。如果要在
htaccess
中将其标记为工作,则需要删除前导斜杠,因为
RewriteRule
指令在
htaccess
中使用相对路径(不带/)

<IfModule mod_rewrite.c>
# Redirect non WordPress pages to corresponding post
RewriteEngine On
RewriteBase /
RewriteRule ^CA_NutritionIncentiveProgram\.htm$ https://theappliancejudge.co.uk/ca_nutritionincentiveprogram [R=301,L,NC]
</IfModule>

#将非WordPress页面重定向到相应的帖子
重新启动发动机
重写基/
重写规则^CA_NutritionInetiveProgram\.htm$https://theappliancejudge.co.uk/ca_nutritionincentiveprogram [R=301,L,NC]

您的原始规则很好,如果在
server.config
上下文中使用,应该可以正常工作。如果要在
htaccess
中将其标记为工作,则需要删除前导斜杠,因为
RewriteRule
指令在
htaccess
中使用相对路径(不带/)

<IfModule mod_rewrite.c>
# Redirect non WordPress pages to corresponding post
RewriteEngine On
RewriteBase /
RewriteRule ^CA_NutritionIncentiveProgram\.htm$ https://theappliancejudge.co.uk/ca_nutritionincentiveprogram [R=301,L,NC]
</IfModule>

#将非WordPress页面重定向到相应的帖子
重新启动发动机
重写基/
重写规则^CA_NutritionInetiveProgram\.htm$https://theappliancejudge.co.uk/ca_nutritionincentiveprogram [R=301,L,NC]

您好,谢谢您的帮助,但它仍然不起作用,请查看我编辑的问题,我将我的问题放在那里,并添加了您的code@FrancisAlvinTan,你能帮我ping一下你正在点击的示例url吗?顺便说一句,这些规则检查路径中是否存在
ca_nutritionncentiveprogram.html
,如果存在,则只会将后端的请求重定向到该路径。Stackoverflow中是否有消息系统?@FrancisAlvinTan,您不需要告诉我确切的url,只需像
http://localhost:80/bla_bla_bla_test
这样就可以了。@FrancisAlvinTan,你能检查一下我编辑的解决方案吗?我对它做了一点小小的修改,请告诉我它是如何运行的,谢谢。嗨,谢谢你的帮助,但它仍然不起作用,请看我编辑的问题,我把我所有的都放在那里,加上你的code@FrancisAlvinTan,你能帮我ping一下你正在点击的示例url吗?顺便说一句,这些规则检查路径中是否存在
ca_nutritionncentiveprogram.html
,如果存在,则只会将后端的请求重定向到该路径。Stackoverflow中是否有消息系统?@FrancisAlvinTan,您不需要告诉我确切的url,只需像
http://localhost:80/bla_bla_bla_test
这样就可以了。@FrancisAlvinTan,你能检查一下我编辑的解决方案吗?我对它做了一点小小的修改,请告诉我它是怎么回事,谢谢你。@Amit Verma非常感谢你,这很有效well@AmitVerma现在我对PDF有这个问题,我如何将它重定向到新的wordpress站点,例如@Amit Verma非常感谢,这很有效well@AmitVerma现在我对PDF有这个问题,我如何将它重定向到新的wordpress站点,例如
<IfModule mod_rewrite.c>
# Redirect non WordPress pages to corresponding post
RewriteEngine On
RewriteBase /
RewriteRule ^CA_NutritionIncentiveProgram\.htm$ https://theappliancejudge.co.uk/ca_nutritionincentiveprogram [R=301,L,NC]
</IfModule>