0

我正在尝试使用 进行永久重定向.htaccess,但它不起作用,我不知道为什么。

RedirectPermanent / http://www.flunchinvite.fr

我正在尝试从:http://www.flunchinvite.com 重定向到: http : //www.flunchinvite.fr

你有什么想法?

谢谢

编辑

我刚刚做了一个测试来重定向到谷歌,但它也不起作用,而当我尝试在http://flunchinvite.fr上使用相同的代码进行重定向时它可以工作。你知道那是从哪里来的吗?

4

4 回答 4

0

At the end I did a php redirection, I don't know why it's not ok on the htaccess. I'll see that another time. I'm going to bed

于 2012-11-12T00:08:57.093 回答
0

Use Rewrite if it is an option:

http://www.gnc-web-creations.com/301-redirect.htm

Another method we can use is via mod_rewrite. This requires that the mod_rewrite module is active on your webserver. It usually is and is done by the system administrators when they installed the webserver. mod_rewrite is a very powerful URL re-writing engine and we will only by scratching a hair on its head here.

Again, in your .htaccess file

RewriteEngine ON RewriteRule ^(.*)$ http://mynewdomain.com/$1 [R=301,L]

The above example will re-map your old domain to a new one and issue a 301 status code (permanent redirect). So a request for

http://olddomain.com/foobar.html will go to

http://mynewdomain.com/foobar.html

If you simply want to redirect all requests regardless of the page requested to the new domain you could use:

RewriteRule /.* http://mynewdomain.com/ [R=301,L]

In this case no matter what file or directory is requested they will all go to

http://mynewdomain.com/ i.e., http://myolddomain.com/foobar.html

will go to http://mynewdomain.com/

The [R=301,L] means redirect the client and send a 301 status code (R=301) and make this the last rule (L).

于 2012-11-11T23:52:54.587 回答
0

看一下第 5 行和第 6 行:

AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /demo2
        RewriteCond %{HTTP_HOST} ^mathpdq\.com
        RewriteRule ^(.*)$ http://www.mathpdq.com/demo2/$1 [R=permanent,L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

我无法让 301 重定向工作,所以我选择了这个。基本上,如果用户使用 mathpdq.com/demo2 进入,它会强制重定向到 www.mathpdq.com/demo2。

第 6 行下面的内容只是到 php 函数的正常映射。

http://pastie.org/5364605

于 2012-11-12T08:58:29.617 回答
0

尝试类似的东西

//Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^flunchinvite.com[nc]
RewriteRule ^(.*)$ http://www.flunchinvite.cfr/$1 [r=301,nc]
于 2012-11-11T23:29:39.410 回答