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中正确的重写规则_.htaccess - Fatal编程技术网

.htaccess htaccess中正确的重写规则

.htaccess htaccess中正确的重写规则,.htaccess,.htaccess,我有一个类似于story/0/1517/s-l-u-g/的URL。在.htaccess文件中,我编写了以下规则,将其带到正确的内部页面 RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^story/([0-9]+)/([0-9]+)/([a-zA-Z0-9]+)\/?$ story_detail.php?catid=$1&sid=$2 [N

我有一个类似于story/0/1517/s-l-u-g/的URL。在.htaccess文件中,我编写了以下规则,将其带到正确的内部页面

RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^story/([0-9]+)/([0-9]+)/([a-zA-Z0-9]+)\/?$ story_detail.php?catid=$1&sid=$2 [NC]
上面的规则不起作用。当我单击它时,它显示“404错误,找不到文件”。我正在使用WAMP


请举例说明我是否做得正确。提前谢谢。

您的模式在这里似乎有问题

试试这个规则:

RewriteEngine on

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^story/([0-9]+)/([0-9]+)/ story_detail.php?catid=$1&sid=$2 [NC,L,QSA]

这将允许slug中的任何内容被传递。

SWEET!!。它就像一个咒语@anubhava。非常感谢和高兴Makar Sakarnatione more question@abnubhava,在上面的htaccess文件中,我有许多重写规则和一个处理404错误的规则。我注意到404错误已经生成,但指定的404.php页面没有显示。为什么会这样??ErrorDocument 404/404.phpI建议为这个404问题打开一个新问题,不要忘记在新问题中放置full.htaccess。它也解决了,