简体   繁体   English

如何使用htaccess文件隐藏部分网址

[英]How to hide a part of the url using htaccess file

I have the following Rewrite rules in my .htaccess file. 我的.htaccess文件中有以下重写规则。

RewriteEngine On
RewriteCond %{HTTPS} !=off
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteRule ^([0-9]+)/([a-zA-Z0-9_-]+)$ system.php?id=$1&title=$2 [L]

With this rules I am getting the url as follows. 有了这个规则,我得到的网址如下。

http://www.example.com/1111/article-title http://www.example.com/1111/article-title

I want to hide the "1111" from the url while passing that to the system.php as an argument.Also I need to add some text instead of "1111". 我想从网址中隐藏“ 1111”,同时将其作为参数传递给system.php。此外,我需要添加一些文本而不是“ 1111”。 So my url should be as follows. 所以我的网址应该如下。

http://www.example.com/text-article-title http://www.example.com/text-article-title

Is there any way to do this? 有什么办法吗? Please give some insight on this. 请对此提供一些见解。

Thanks. 谢谢。

Try this 尝试这个

RewriteCond %{REQUEST_URI} !^example.com/1111/article-title [NC]
RewriteRule ^example.com/(.*)$ example.com/text-article-title/$1 [L]

that should do the trick. 这应该够了吧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM