English 中文(简体)
httaccess 专家: 将除 root 以外的全部重定向到一个 TLD, 将 root 重定向到另一个 TLD - WordPress
原标题:htaccess experts: Redirect all but root to one TLD, redirect root to another TLD - WordPress

感谢导师的帮助。

我被要求将客户端的 WordPress 主页放在一个 TLD( 即域名. eu) 上, 并且将所有其他网页/ 日志为 301 d 的 不同的 TLD 扩展名( 域名. com/ everything- ele) 。 不清楚为什么有人要求这样做, 但显然这对客户很重要, 而我一直在敲我的头来工作。 有什么想法吗?

<强>EXAMPLES:

如果 URL 点击任何域域 TLD 根, 则应该将其重定向到.eu 域( http://domain.eu/), 但其它所有内容都应该转到.com 域( http://domain. com/) 。

<强 > roots:

http://domain.com  OR
http://domain.net  OR
http://domain.edu/index.php OR
http://domain.org/index.html  OR
http://domain.* (* = any extension)

301 to: http://domain.eu" rel="nofollow">http://domain.eu

<他们>然而,其他所有 都需要维持目录结构,并重新定位到其他端点(http://domain.com.),例如。

<强 > 发件人:

    http://domain.net/blog/category

< 加固>301 收件人:

    http://domain.com/blog/category

<强 > 发件人:

    http://domain.org/blog/category/post

< 加固>301 收件人:

    http://domain.com/blog/category/post

我尝试过的一切最终都是在重定向循环中完成的,或者只是部分成功。例如,下面将置于WordPress重定向之上,而它又正确地重定向,因为所有目标 URL 都被击中了,但根(主页) 有一个重定向循环错误。有什么想法吗?

RewriteEngine On
RewriteBase /
Options +FollowSymLinks

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

RedirectMatch ^/$ http://domain.eu

RewriteCond %{REQUEST_URI} !^/$ [NC]
RewriteCond %{HTTP_HOST} ^domain.com.au$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domain.eu$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domain.de$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

我有点新手了,让我知道 我是怎么搞错的,谢谢!

最佳回答

尝试用以下方式替换重定向匹配 。

RewriteCond %{HTTP_HOST} !^domain.eu$ [NC]
RewriteRule ^/?$ http://domain.eu/ [R=301,L]
问题回答

WordPress 将重定向 WordPress 配置中与域不匹配的任何 URL 。 您要么需要写入 WWP 插件, 要么使用代理来抓取另一个域的主页 。





相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签