如何使用.htaccess重写HTTP获取请求 [英] how to rewrite HTTP get request with .htaccess

查看:121
本文介绍了如何使用.htaccess重写HTTP获取请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要 .htaccess 规则才能重新路由:

I need .htaccess rule to reroute:

example.com/view -post.php?id = 40 example.com/article/40

因此浏览器在地址栏中显示 example.com/article/40 ,但服务器使用 example.com/view-post.php?id=40

So browser shows example.com/article/40 in address bar but server uses example.com/view-post.php?id=40

推荐答案

以下作品:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^article/(\d+)*$ ./view-post.php?id=$1

引用: https: //code.tutsplus.com/tutorials/using-htaccess-files-for-pretty-urls--net-6049

这篇关于如何使用.htaccess重写HTTP获取请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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