Php 对具有参数的域使用URLEWRITE
我想将example.com/index.php?post_id=1&seri_id=5重写为example.com/seri-name/post-name 我发现: 在web根目录.htaccess文件中存储以下内容: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
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'));
但我不明白我怎么能重写这个过程。有人能帮忙吗?这是做我想做的事情的最好方式吗?有什么我可以编辑来改进的吗?从技术上讲,应该是这样。这是我想要的正确方法吗?