下面提到的代码在.htaccess中做什么?

下面提到的代码在.htaccess中做什么?,.htaccess,serp,.htaccess,Serp,有人能告诉我下面的代码是什么吗 RewriteEngine On RewriteCond %{HTTP_HOST} ^example-old.com$ RewriteRule (.*) http://www.example-new.com/$1 [R=301,L] 是否只有在有人准确键入example-old.com时才有效?带有文件夹的URL会发生什么情况,例如example-old.com/folder1和example-old.com/folder1/sub1/page1.php 我的一

有人能告诉我下面的代码是什么吗

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example-old.com$
RewriteRule (.*) http://www.example-new.com/$1 [R=301,L]
是否只有在有人准确键入example-old.com时才有效?带有文件夹的URL会发生什么情况,例如example-old.com/folder1和example-old.com/folder1/sub1/page1.php

我的一个客户的网站成了一场灾难。下面是.htaccess和谷歌搜索页面中的代码。当打开时,它会在每个URL的末尾添加一个额外的“/”来显示一个可怕的页面。我无法确定代码中的错误在哪里:

Options -Indexes
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example-old.com$
RewriteRule (.*) http://www.example-new.com/$1 [R=301,L] 

RewriteCond %{HTTP_HOST} ^www.example-old.com$
RewriteRule (.*) http://www.example-new.com/$1 [R=301,L] 

RewriteCond %{HTTP_HOST} ^example-new.com$
RewriteRule (.*) http://www.example-new.com/$1 [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
RewriteCond %{HTTP_HOST} ^example-old\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example-old\.com$
RewriteRule ^2015\/?(.*)$ "http\:\/\/www\.example-old\.com\/$1" [R=301,L]
而不是打开带有URL的页面:-

它将打开:

出于安全原因,我使用旧示例和新示例。请帮忙

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example-old.com$
RewriteRule (.*) http://www.example-new.com/$1 [R=301,L]
这会将example.com/foo/foobar永久重定向到example new.com/foo/foobar

RewriteCond %{HTTP_HOST} ^example-old.com$
RewriteRule (.*) http://www.example-new.com/$1 [R=301,L]
在php上下文中,您将使用

if(host == "example.com" and Request_uri== "any request")
 {header('location : host/Request_uri',301)
else
{no redirection}
这会将example.com/foo/foobar永久重定向到example new.com/foo/foobar

RewriteCond %{HTTP_HOST} ^example-old.com$
RewriteRule (.*) http://www.example-new.com/$1 [R=301,L]
在php上下文中,您将使用

if(host == "example.com" and Request_uri== "any request")
 {header('location : host/Request_uri',301)
else
{no redirection}