隐藏URL htaccess的部分

编程入门 行业动态 更新时间:2024-10-25 08:25:10
本文介绍了隐藏URL htaccess的部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

目标:

  • 在该网站的用户登陆,其中最新的10篇文章显示(没有问题就在这里)。
  • 使用该的href用户点击一篇文章的标题表中的链接:

    < A HREF =。。ar​​ticle.php /".$输入/的$ id/$ web_title。>中$称号。 < / A>

    我有这个URL重写我的htaccess文件:

    I've got this URL rewrite in my htaccess file:

    RewriteEngine On RewriteCond %{REQUEST_URI} ^/article/? RewriteCond %{REQUEST_FILE} !-f RewriteCond %{REQUEST_FILE} !-l RewriteRule ^(.*)$ article.php?post_type=$1&post_id=$2&post_name=$3 [QSA,L]

    这是生产的网址: example/article.php/news/1/first-article-test 当用户访问 article.php 通过2点所述的链接。

    Which is producing the URL: example/article.php/news/1/first-article-test when the user accesses article.php via a link described in point 2.

    我试图删除上述网址 article.php 部分,因此它看起来就像这样:   example/news/1/first-article-test

    I'm trying to remove the article.php section from the above URL, so it looks just like this: example/news/1/first-article-test

    目前在 article.php 页接收变量就好了,它是从基于 $ id数据库拉低其他数据通过了链接,但该URL显示 article.php /...。

    At the moment the article.php page is receiving the variables just fine, it's pulling down other data from the database based on the $id passed by the link, but the URL is displaying article.php/....

    推荐答案

    请您的规则是这样的:

    RewriteEngine On RewriteCond %{REQUEST_FILE} !-f RewriteCond %{REQUEST_FILE} !-l RewriteCond %{REQUEST_URI} !^/article\.php [NC] RewriteRule ^(.+)$ /article.php/$1 [L]

    这会让你有你的链接作为

    It will let you have your links as

    example/news/1/first-article-test
  • 更多推荐

    隐藏URL htaccess的部分

    本文发布于:2023-10-31 18:38:07,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1546937.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:URL   htaccess

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!