Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/264.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 使用.htaccess创建漂亮的URL_Php_Linux_Apache_.htaccess - Fatal编程技术网

Php 使用.htaccess创建漂亮的URL

Php 使用.htaccess创建漂亮的URL,php,linux,apache,.htaccess,Php,Linux,Apache,.htaccess,我希望以这种格式创建漂亮的URL www.example.com/countryId/stateid,但我希望我的API端点路由到/public folder中的index.php Options +FollowSymLinks RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^ index.php [L] 我一直收到404的错误,我不知道我

我希望以这种格式创建漂亮的URL www.example.com/countryId/stateid,但我希望我的API端点路由到/public folder中的index.php

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^ index.php [L]
我一直收到404的错误,我不知道我在哪里得到它的错误。
这是我的URL“”,我希望URL端点路由到。.htaccess文件存在于public/.htaccess中,其中index.php为

请参考此答案,这将意味着重构整个应用程序,因为在某个时刻,应用程序正在以某种方式运行,您必须捕获正在重定向的url片段;否则,您将如何显示不同的页面?如果应用程序在某个时候工作,请查看它是如何获得这些信息的,这将使您了解htaccess需要如何将这些信息提供给index.php