Articles of 301redirect

.htaccess重写迁移的WordPress网站

我已经将我的Wordpress从一个域移动到另一个域,我希望使用.htaccess 301redirect将旧域上的postredirect到新域上的post。 我的networking主机build议我尝试以下内容: Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?steve\.doig\.com\.au/wordpress/$ [NC] RewriteRule ^(.*)$ http://www.superlogical.net/$1 [R=301,L] 这只适用于/ wordpress文件夹,但不适用于任何类别的页面或post。 这里有什么问题?

如果我的.htaccess被设置为从abc.com到xyz.com的301,那么会导致abc.com改为302?

以下是我的.htaccess文件的样子: Options +FollowSymlinks RewriteEngine on #rewritecond %{http_host} !^abc.com/* [nc] #rewriterule ^(.*)$ http://www.xyz.com/$1 [r=301,L] 但是当我检查abc.com的标题时,我得到: Status: HTTP/1.1 302 Object moved abc.com和xyz.com托pipe在同一台服务器上; xyz.com是新的域名。 是否有东西取代了原来的.htaccess? 我曾要求托pipe公司做redirect,他们说他们使用他们的“公园领域”function来做。 但我仍然不确定如何防止遵循.htaccess规则。

我应该使用什么redirect规则来replace这个301redirect,在Apache?

我正在使用此指令redirect到HTTPS : <VirtualHost *:80> ServerName foo.bananas.net Redirect 301 / https://foo.bananas.net </VirtualHost> 问题是,当在地址栏中使用path时,如http://bananas.net/webpage ,在https://bananas.netwebpage (无斜杠)失败之前需要暂停一段时间。 应该使用重写规则吗? 应该怎么做,我应该知道的行为有什么不同?

301在同一托pipe服务器上redirect

我最初买了一个托pipe软件包的域名http://example.com ,并运行了一段时间的博客。 现在我已经买了一个域名http://example.com.au添加并重复的内容,但现在想写一个301redirect。 由于新域名是原始服务器的插件,它共享.htaccess文件,我实现的一般301redirect导致无限redirect循环。 什么是正确的方法来做到这一点? 我试图按照这里发布的早期post上的指示。 基本上插入这个: Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^www.example.com [NC] RewriteRule (.*) http://www.example.com.au/$1 [R=301,L]

如何在301redirect中使用旧URL的部分

是否有可能保留一个URL的某些部分,并重写其余部分? 使用.htaccess 301redirect。 在我的例子中,我想重写这种格式的url http://blog.example.com/post-name 到这一个 http://example.com/2014/post-name 到目前为止,2014年(2014年)可能是静态的,因为只有一些链接会受到影响。 谢谢!

Nginx 301将httpsredirect到http

我有一个奇怪的问题,尾随/ 我正在使用nginx,它有一个小例外正常运行。 我有以下网站configuration server { listen 80; return 301 https://$server_name$request_uri/; server_name sub1.sub2.domain.com; } server { listen 443 ssl; # The ssl directive tells NGINX to decrypt # the traffic server_name sub1.sub2.domain.com; ssl_certificate /etc/nginx/ssl/sub1.sub2.domain.com/server.crt; # This is the certificate file ssl_certificate_key /etc/nginx/ssl/sub1.sub2.domain.com/server.key; # This is the private key file location / { proxy_pass http://1.1.1.1:8880; proxy_redirect off; […]

IPTables转发端口8080到80

我的硬件防火墙已打开端口8080 我的目标是让我的服务器通过8080接收请求,并通过iptables路由请求由httpd处理。 这似乎很简单(在我的脑海中),但我错过了一些东西。 这是我的IPTable规则: *nat :PREROUTING ACCEPT [6:782] :POSTROUTING ACCEPT [1:732] :OUTPUT ACCEPT [1:732] -A PREROUTING -i eth1 -p tcp -m tcp –dport 8080 -j DNAT –to-destination :80 COMMIT *filter :INPUT DROP [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [87:12324] -A INPUT -m state –state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT […]

如何将页面从目录redirect到子目录?

我最近把我网站上的所有内容从www.mysite.com/shop目录移到了根目录中。 这意味着我需要redirect任何请求访问页面与/shop目录回到根目录中的同一页面,例如。 www.mysite.com/shop/categories/washroom 至 www.mysite.com/categories/washroom 这需要发生在我以前使用/shop目录的网站中的所有页面。 我在这里得到了一个解决scheme,那就是: RedirectMatch (^/shop/)(.*) http://www.mysite.com/$2 它完美的工作,但现在我不得不切换到使用我们的旧版本的软件,位于/shop目录,所以我需要现在完全相反的redirect,例如。 www.mysite.com/categories/washroom 至 www.mysite.com/shop/categories/washroom 任何人都可以帮我吗?

最快的加载:在PHP中使用标题位置redirect,或用Apache重写?

在意识到主页redirect的主要滞后之后,我读入了许多优化线程,certificate了301redirect在大约100ms内猛增了400ms,超出了总加载时间。 在我的网站大约250ms。 傻我知道! 另一方面,我确实需要redirect到默认语言,因为不同语言的其他域。 我有什么工作,但每一次最浪费250毫秒。 无论如何,这可以做得更快吗? 通过htaccess重写也许? 目前有 index.php <?php switch($_SERVER["HTTP_HOST"]){ case "site.org": header('HTTP/1.1 301 Moved Permanently'); header('Location: /en/home'); # extensio .php is hidden: 'home' is a file case "site.fr": header('HTTP/1.1 301 Moved Permanently'); header('Location: /fr/home'); # extensio .php is hidden: 'home' is a file etc etc ?> 我努力了 简单地包括home为第一个主页的作品漂亮, 但在浏览器中的url是不是设置为site.org/en/home你只是看到site.org和所有的链接,然后不再工作。 我需要的是,主页加载和浏览器中的url变成/xx/home 任何和所有的线索都非常赞赏+1

如何使用HTTP 301redirect来移动网站和切换链接结构

我目前有我的WordPress的博客(Apache2,Ubuntu的Linux)在例如mysite.com托pipe使用基于ID的链接,例如http://mysite.com/?p=547 。 我有两个目标: 将我的博客移至mysite.com/blog 将链接结构更改为/{post-title}而不是/?p={post-id} 移动到新的结构应该很简单 ,就像改变WordPress的设置使用新的永久链接结构一样。 我也想做的是不打破目前链接到我的random(1..100)网站 。 我想使用HTTP 301永久redirect,但我不知道如何通过更改Apache的设置来做到这一点。 第一个问题将是处理redirect到/blog/所有请求。 第二个问题将是处理新的链接结构。 我想我可以很容易地查询MySQL数据库,并生成类似于?p={post-id} > {post-title} ,但我不知道什么语法应该看起来像什么,我需要把它放在哪里。 任何帮助将非常感激。