隐藏URL htaccess的部分 [英] Hide Part of URL htaccess
问题描述
目标:
- 在该网站的用户登陆,其中最新的10篇文章显示(没有问题就在这里)。
-
使用该
的href用户点击一篇文章的标题
表中的链接:
< A HREF =。。article.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]
这是生产的网址: http://example.org/article.php/news/1/first-article-test
当用户访问 article.php
通过2点所述的链接。
Which is producing the URL: http://example.org/article.php/news/1/first-article-test
when the user accesses article.php
via a link described in point 2.
我试图删除上述网址 article.php
部分,因此它看起来就像这样:
http://example.org/news/1/first-article-test
I'm trying to remove the article.php
section from the above URL, so it looks just like this:
http://example.org/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
http://example.org/news/1/first-article-test
这篇关于隐藏URL htaccess的部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!