Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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 对具有参数的域使用URLEWRITE_Php_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php 对具有参数的域使用URLEWRITE

Php 对具有参数的域使用URLEWRITE,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我想将example.com/index.php?post_id=1&seri_id=5重写为example.com/seri-name/post-name 我发现: 在web根目录.htaccess文件中存储以下内容: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d

我想将example.com/index.php?post_id=1&seri_id=5重写为example.com/seri-name/post-name

我发现:

在web根目录.htaccess文件中存储以下内容:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
在上面的示例中,所有URL都发送到index.php脚本。 获取index.php中的URL,如下所示:

$route = $_SERVER['PHP_SELF'];
$route = substr($route, strlen('/index.php'));

但我不明白我怎么能重写这个过程。有人能帮忙吗?这是做我想做的事情的最好方式吗?有什么我可以编辑来改进的吗?

从技术上讲,应该是这样。这是我想要的正确方法吗?