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-以永不结束的方式循环_.htaccess_Redirect - Fatal编程技术网

.htaccess-以永不结束的方式循环

.htaccess-以永不结束的方式循环,.htaccess,redirect,.htaccess,Redirect,我有一个.htaccess文件,如下所示: <FILES update> ForceType application/x-httpd-php </FILES> Options -Indexes ServerSignature Off Options +FollowSymLinks # To prevent E_STRICT problems with PHP 5.3+ you can uncomment the following lines # Note: Thes

我有一个.htaccess文件,如下所示:

<FILES update>
ForceType application/x-httpd-php
</FILES>
Options -Indexes
ServerSignature Off

Options +FollowSymLinks

# To prevent E_STRICT problems with PHP 5.3+ you can uncomment the following lines
# Note: These settings should only be enabled for production sites!
#php_flag display_startup_errors 0
#php_flag display_errors 0
#php_flag html_errors 0
#php_value docref_root 0
#php_value docref_ext 0

<IfModule mod_rewrite.c>
RewriteEngine on
#
#Sub-dir e.g: /cmsms
RewriteBase /

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# but ignore POST requests.
#RewriteCond %{REQUEST_URI} !/$
#RewriteCond %{REQUEST_URI} !\.
#RewriteCond %{REQUEST_METHOD} !POST$
#RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
</IfModule>

<IfModule mod_header.c>
# Disable ETags
Header unset ETag
FileEtag None
</IfModule>

<IfModule mod_deflate.c>
# Compress css, plaintext, xml, gif, and images in transport.
AddOutputFilterByType DEFLATE text/css text/plain text/xml image/gif image/jpeg image/png
</IfModule>

<IfModule mod_expires.c>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
# Set expires tags on various files... so that the browser wont attempt to reload them.
ExpiresActive On
ExpiresDefault "access plus 1 year"
<IfModule mod_header.c>
  # Setting cache control to public allowes proxy servers to cache the items too.
  Header set Cache-Control "public"
</IfModule>
</FilesMatch>
</IfModule>

但是我不知道如何在不引起循环的情况下做到这一点。

您需要在前面添加
http://

rewritecond %{HTTP_HOST} ^olddomain.com [nc]
rewriterule ^(.*)$ http://newdomain.com/$1 [r=301,nc]

你也应该把它放在其他重写规则之前。

我在Rewritebase/(当然是不同的时间)之前和之下添加了它,但之后我一直收到一个404错误?
%{HTTP_HOST}
我想必须用大写字母。你说的一直得到404是什么意思?在你最初的问题中,你说的是一个无限循环,而不是404未找到的错误。我把它改为大写。我的意思是,在我设置它之后,而不是无限循环,网页将加载,但显示404错误?DNS配置正确,因为您可以查看两个域的网页。
rewritecond %{HTTP_HOST} ^olddomain.com [nc]
rewriterule ^(.*)$ http://newdomain.com/$1 [r=301,nc]