Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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 导致内部服务器错误的基本URL重写_Php_.htaccess_Url Rewriting - Fatal编程技术网

Php 导致内部服务器错误的基本URL重写

Php 导致内部服务器错误的基本URL重写,php,.htaccess,url-rewriting,Php,.htaccess,Url Rewriting,我对这一点很陌生,读过几篇关于URL重写的文章 我只想更改www.domain.com/single recipe.php?id=6 访问www.domain.com/recipes/6 从教程中,我在.htaccess中找到了以下代码 RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www.domain.com [NC] RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301] R

我对这一点很陌生,读过几篇关于URL重写的文章

我只想更改www.domain.com/single recipe.php?id=6

访问www.domain.com/recipes/6

从教程中,我在.htaccess中找到了以下代码

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

RewriteRule    ^recipes/([0-9]+)/?$    single-recipe.php?id=$1    [NC,L]    # Handle recipe requests
当我试图访问网站上的任何页面时,我会遇到一个可爱的内部服务器错误500


如果您有任何帮助,我们将不胜感激。

我认为这是因为有额外的空间。请将其移除,然后尝试:

RewriteRule ^recipes/([0-9]+)/?$ single-recipe.php?id=$1[NC,L]

感谢您修复了内部服务器错误。现在,当我在domain.com/recipes/1中键入时,我得到一个404/single-recipe.php未找到。文件single-recipe.php是否存在?如果我转到domain.com/single recipe?id=1,它将在该行中加载删除
^
,然后尝试,
重写规则recipes/([0-9]+)/?$single recipe.php?id=$1[NC,L]