Redirect 如何将动态URL转换为静态URL-以便PHP将URL发送到浏览器,然后.htaccess将其转换并发送回PHP

Redirect 如何将动态URL转换为静态URL-以便PHP将URL发送到浏览器,然后.htaccess将其转换并发送回PHP,redirect,mod-rewrite,dynamic,static,directoryindex,Redirect,Mod Rewrite,Dynamic,Static,Directoryindex,我不熟悉.htaccess,我试着用谷歌搜索我遇到的每一个问题.htaccess来理解。我发现很少有教程,但我什么都不懂 第一个问题: 与.htaccess相关的输入url和输出url之间有什么区别 第二个问题: PHP,在我的索引页中 header('Location:http://example.com/index.php?p=test&c=math&t=geometry&id=100'); 我想要的浏览器url是 http://example.com/test/

我不熟悉.htaccess,我试着用谷歌搜索我遇到的每一个问题.htaccess来理解。我发现很少有教程,但我什么都不懂

第一个问题: 与.htaccess相关的输入url和输出url之间有什么区别


第二个问题:

PHP,在我的索引页中

header('Location:http://example.com/index.php?p=test&c=math&t=geometry&id=100');
我想要的浏览器url是

http://example.com/test/math/geometry/100
使用htaccess,我想将下面的url返回到php

http://example.com/index.php?p=test&c=math&t=geometry&id=100

第三个问题:

如果以某种方式,上述情况是可能的 我该怎么做 在php中,在索引页中

header('Location:http://example.com/index.php?p=test&t=geometry&id=100');
使用.htaccess,我想在url上获取以下代码

http://example.com/test/geometry/100
php应该从.htaccess获取以下代码

http://example.com/index.php?p=test&t=geometry&id=100

第四个问题: 请帮助我,我也找到了下面的解决方案,我无法理解下面的代码中发生了什么

RewriteEngine on
DirectoryIndex index.php

# REDIRECT Force requests for named index files to drop the index file filename, and force non-www to avoid redirect loop
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*index\.(html?|php[45]?)(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]*/)*)index\.(html?|php[45]?)$ http://example.com/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+)/([^\.]+)\.php\ HTTP/
RewriteRule ^([a-zA-Z0-9_-]+)/([^.]+)\.php$ http://example.com/$1/$2 [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+)/([^/]+)/([^\.]+)\.php\ HTTP/
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([^.]+)\.php$ http://example.com/$1/$2/$3 [R=301,L]

# REDIRECT www to non-wwww
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteRule .? http://example.com%{REQUEST_URI} [R=301,L]

# REWRITE url to filepath
RewriteRule ^([a-zA-Z0-9_-]+)/([^/.]+)$ /$1/$2.php [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([^/.]+)$ /$1/$2/$3.php [L]
提前谢谢