【教程】phpstudy设置伪静态

  1. 开启phpstudy扩展,勾选“rewrite_module”

    image.png

  2. 开启phpstudy伪静态支持,打开httpd-conf,修改所有“AllowOverride None”为“AllowOverride All”

    image.png

    image.png

  3. 修改并保存后,需重启Apache服务器

  4. 在网站根目录下添加.htaccess文件,创建时需要使用文本编辑器进行另存为创建,比如Editplus

  5. .htaccess文件代码

    RewriteEngine on
  RewriteRule ([a-zA-Z]{1,})-([0-9]{1,}).html$ index.php?action=$1&id=$2

    其中,html后的$符号表示结束,后跟一个空格,$1和$2表示参数

    测试:

    我的.htaccess代码是

  RewriteEngine on
  RewriteRule article/index-([0-9]{1,}).html$ article/index.html?id=$1

    在浏览器地址栏输入 http://localhost/article/index-1.html 

    会重定向到http://localhost/article/index.html?id=1

    在index.html中获取参数的方法为:

function GetRequest() {  
   var url = window.location.href; //获取url中"?"符后的字串  
   var str=url.split("-")[1].split(".")[0];
   return str;  
}  
console.log(window.location.href);
console.log(GetRequest());

完成。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hifhf

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值