Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.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
Php 重定向301。htaccess不工作_Php_.htaccess_Redirect - Fatal编程技术网

Php 重定向301。htaccess不工作

Php 重定向301。htaccess不工作,php,.htaccess,redirect,Php,.htaccess,Redirect,下面是我的htaccess和重定向301不工作。有什么想法吗 order allow,deny allow from all Options -Indexes Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRu

下面是我的htaccess和重定向301不工作。有什么想法吗

order allow,deny allow from all Options -Indexes Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php [L] Redirect 301 /index.php?id=4 site.com/newdirectory/ 命令允许,拒绝 通融 选项-索引 选项+FollowSymLinks 重新启动发动机 重写基/ 重写cond%{REQUEST_FILENAME}-D 重写cond%{REQUEST_FILENAME}-F 重写规则。index.php[L] 重定向301/index.php?id=4 site.com/newdirectory/
订单
指令不需要,只需取出即可。此外,您无法匹配
重定向
指令中的查询字符串,请使用
mod_rewrite
RewriteCond
,如下所示:

RewriteEngine On 
RewriteBase /

RewriteCond %{QUERY_STRING} ^id=4$ [NC]
RewriteRule ^index\.php$ /newdirectory/? [L,NC,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

-1:为什么
order allow,deny
如果你要从所有人那里拒绝&请定义“不工作”。我有一个重定向:redirect 301/index.php?id=4 site.com/newdirectory/这个不工作你已经说过了,这如何回答我的问题?什么是“不工作”呢?您使用的是什么版本的Apache?(请记住,您的allow、deny语法将是,无论编写它是否合理。。。我放弃了…@anuhava请注意,在这种情况下,
[NC]
标志应该位于
重写条件
,而不仅仅是
重写规则
。此外,默认情况下,
[R]
会发出一个
302
(临时)重定向,因此无需指定响应代码,除非您希望发出其他类型或重定向。(对于不知道您可以更改响应代码的任何人,从技术上讲,您可以使用任何代码,但只有3xx范围内的代码才能正常工作。您也可以通过关键字引用最常见的类型:
temp
=
302
永久性
=
301
,以及
参见其他
=
303