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
.htaccess 301将任何页面重定向到一个特定页面_.htaccess - Fatal编程技术网

.htaccess 301将任何页面重定向到一个特定页面

.htaccess 301将任何页面重定向到一个特定页面,.htaccess,.htaccess,有没有一种方法可以通过htaccess 301重定向将域上的任何页面重定向到另一个域上的特定页面 例如,我被domain.com/index.html和domain.com/contact.html重定向到newsite.com/index.html 但我想这样做,而不必列出每一页的具体内容 我的301重定向能像这样吗 301 * http://newsite.com/index.html 或者应该如何设置。不幸的是,我没有mod rewrite的访问权限,因此我无法使用mod rewrite

有没有一种方法可以通过htaccess 301重定向将域上的任何页面重定向到另一个域上的特定页面

例如,我被
domain.com/index.html
domain.com/contact.html
重定向到
newsite.com/index.html

但我想这样做,而不必列出每一页的具体内容

我的301重定向能像这样吗

301 * http://newsite.com/index.html
或者应该如何设置。不幸的是,我没有mod rewrite的访问权限,因此我无法使用mod rewrite来使其工作。

是的,这是可能的——您需要使用mod_alias来代替mod_rewrite(它有更多的机会被启用)

这将把一切重定向到
newsite.com/

RedirectMatch 301 ^/(.*)$ http://newsite.com/index.html
这一个将把所有内容重定向到另一个域上的同一路径:(例如,
oldsite.com/meow.php
=>
newsite.com/meow.php


在使用wordpress并试图从页面中删除所有.asp扩展名时,出现了与此类似的问题,这可以粘贴到我的.htaccess文件的顶部

## 301 Redirects
RewriteCond %{QUERY_STRING}  ^$
RewriteRule ^(.*)\.asp$ $1? [R=301,NE,NC,L]
## 301 Redirects
RewriteCond %{QUERY_STRING}  ^$
RewriteRule ^(.*)\.asp$ $1? [R=301,NE,NC,L]