htaccess的 - 删除的index.php,但不是index.php的index.php文件时,Z = ABC? [英] htaccess - removes index.php, but not index.php when index.php?z=abc

查看:123
本文介绍了htaccess的 - 删除的index.php,但不是index.php的index.php文件时,Z = ABC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTTP:// domain.com/index.php - > HTTP:// domain.com/ - 确定

HTTP:// domain.com/index.php?z=abc - > HTTP:// domain.com/index.php?z=abc - 也不行,保持不变。 这个工程使用下面的code:

  RewriteEngine叙述上
的RewriteCond%{THE_REQUEST} ^ [AZ] {3,9} \ /.*指数\ .PHP \ HTTP /
重写规则^(。*)指标\的.php / $ 1 [R = 301,L]
 

如何修改此code,这样

 的http:// domain.com/index.php?z=abc  - > HTTP:// domain.com/?z=abc
 

解决方案

Apache会自动照顾查询字符串。所有你需要的是这样的:

  RewriteEngine叙述上
重写规则^的index.php / [L,R = 301]
 

http:// domain.com/index.php -> http:// domain.com/ - OK

http:// domain.com/index.php?z=abc -> http:// domain.com/index.php?z=abc - not OK, stays the same. This works using the code below:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]

How to modify this code so that

http:// domain.com/index.php?z=abc -> http:// domain.com/?z=abc

解决方案

Apache will take care of the query string automatically. All you need is this:

RewriteEngine on
RewriteRule ^index.php / [L,R=301]

这篇关于htaccess的 - 删除的index.php,但不是index.php的index.php文件时,Z = ABC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆