Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/63.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 将所有URL重定向到主域访问_.htaccess_Url Redirection - Fatal编程技术网

.htaccess 将所有URL重定向到主域访问

.htaccess 将所有URL重定向到主域访问,.htaccess,url-redirection,.htaccess,Url Redirection,我想将我所有的URL重定向到www.domain.com www.domain.com/site-1 must redirect to www.domain.com www.domain.com/site-2 must redirect to www.domain.com a.s.o 我试过: RewriteEngine On RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301] 但在执行此操作时,我被重定向到:这是一个白色页

我想将我所有的URL重定向到www.domain.com

www.domain.com/site-1 must redirect to www.domain.com
www.domain.com/site-2 must redirect to www.domain.com
a.s.o
我试过:

    RewriteEngine On
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]
但在执行此操作时,我被重定向到:这是一个白色页面,而不是主页,您可以使用:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . http://www.mydomain.co.uk/? [R=301,L]

谢谢,但是当添加你的重写规则时,页面正在加载,加载,加载,主页永远不会弹出…你还有其他规则吗?我刚刚删除了所有规则,只在重写规则上放入了重写引擎。/?[R=301,L]它不加载模块、样式表等。。。添加css/js问题的rewriteruleok时,仅使用菜单文本和文本,只需在css、js、图像文件中使用绝对路径,而不是相对路径。这意味着您必须确保这些文件的路径以
http://
或斜杠
/
开头。您可以尝试将其添加到页面的HTML标题中:
,以便从该URL而不是当前URL解析每个相对URL。