从 URL 中删除页面 + 查询字符串 [英] Remove page + query string from URL

查看:81
本文介绍了从 URL 中删除页面 + 查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个旧的 URL 语法,自从我改变了我的 CMS,旧的语法不再起作用,我有很多 404 错误.我想在这里删除article.php?p=":

I have an old URL syntax and since I changed my CMS, the old syntax doesn't work anymore and I have a lot of error 404. I want to delete "article.php?p=" here :

到:

如何使用 htaccess 从我的 URL 中完全删除字符串article.php?p="?我尝试了很多东西,但对我来说似乎太难了.

How can I totally remove the string "article.php?p=" from my URLs with htaccess please ? I tried a lot of things but it seems too difficult for me.

推荐答案

要将旧 URL 重定向到新 URL,您必须首先从带有 RewriteCond 然后在 RewriteRule

To redirect the old URL to the new one, you must first capture the page's name from the query string with RewriteCond and then use this in RewriteRule

RewriteCond &%{QUERY_STRING}& &p=(.*?)&
RewriteRule ^article\.php$ /%1? [R,L]

这篇关于从 URL 中删除页面 + 查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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