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 精确表达式的mod_重写规则不起作用_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess 精确表达式的mod_重写规则不起作用

.htaccess 精确表达式的mod_重写规则不起作用,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我对mod_rewrite没有太多的工作,所以我很容易就会错过一些简单的东西。我想匹配并替换一个特定的URL。我要重写的URL如下所示: 至 My htaccess当前有以下规则: RewriteRule^(hello)/?$index.php?页面=$1[L] 但是,当我实现规则并通过尝试转到或对其进行测试时,我总是会收到404错误文档。呃,我觉得这应该很简单,我一定是错过了什么。任何帮助都将是美妙的,非常感谢 这是我的全部档案供参考: Options +FollowSymlinks -Mul

我对mod_rewrite没有太多的工作,所以我很容易就会错过一些简单的东西。我想匹配并替换一个特定的URL。我要重写的URL如下所示:

My htaccess当前有以下规则:

RewriteRule^(hello)/?$index.php?页面=$1[L]

但是,当我实现规则并通过尝试转到
对其进行测试时,我总是会收到404错误文档。呃,我觉得这应该很简单,我一定是错过了什么。任何帮助都将是美妙的,非常感谢

这是我的全部档案供参考:

Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?sample\.com/ [NC]
RewriteCond %{REQUEST_URI} !hotlink\.(gif|png) [NC]
RewriteRule ^(.*)\.(gif|jpe?g|png)$ sample.com/hotlink.png[R,NC,L]

RewriteCond %{HTTP_HOST} ^www.sample\.com$ [NC]
RewriteRule ^(.*)$ http://sample.com/$1 [R=301,L]

RewriteRule ^(hello)/?$ index.php?page=$1 [L]

谢谢

你的代码对我来说非常好。也许你失踪了

RewriteEngine On
RewriteRule ^(hello)/?$ page.php?page=$1 [L]
或者可能根本没有安装或加载mod_rewrite。 寻找

LoadModule rewrite_module libexec/apache2/mod_rewrite.so

在主apache配置文件httpd.conf中,这是其中一次

我清除了htaccess文件,只使用了以下几行,并对其进行了测试:

Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteBase /
#
RewriteRule ^(hello)/?$ page.php?page=$1 [L]
我意识到在查看非定制404页面时,它引用了page.php而不是index.php

Not Found

The requested URL /page.php was not found on this server.
因此,在我所有的编辑中,我都错误地在规则中键入了page.php,而不是index.php。我纠正了它,规则也起作用了。其中一次:)


谢谢大家

mod_rewrite是否已启用,重写引擎是否已激活?是的-我对非www到www的重写规则运行良好,并且我已启用了rewrite engine Onhm,您能否向我们展示整个.htaccess?也许你的规则是以某种方式相互作用的?老实说,我的网站是托管在godaddy上的,所以我甚至不知道在哪里可以找到mod_重写。所以,我有其他网站也托管在godaddy上,在相同的计划下,mod_重写在这些网站上工作。。。