使用 .htaccess 更改 url

发布于 2025-01-05 03:12:48 字数 333 浏览 0 评论 0原文

我有一个以下格式的网址:

http://example.com/realestate/index.php?page=services.html

如何使用 .htaccess 文件将其更改为以下格式?

http://example.com/services.html

因此, index.php?page= 被省略,只有 services.html 部分显示在浏览器中 网址。

我对编写 .htaccess 文件一无所知。

I have an url in the following format:

http://example.com/realestate/index.php?page=services.html

How can change it to the following format with a .htaccess file?

http://example.com/services.html

So that index.php?page= is omitted and only services.html part is shown in the browser's
url.

I dont know anything about writing .htaccess files.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不乱于心 2025-01-12 03:12:48

尝试这样的操作:

RewriteEngine on
RewriteRule (.*)\.html http://example.com/index.php?page=$1 [L]

现在 url xyz.com/services.html 将被重写为 xyz.com/index.php?page=services.html

Try something like this:

RewriteEngine on
RewriteRule (.*)\.html http://example.com/index.php?page=$1 [L]

Now the url xyz.com/services.html would be rewritten to xyz.com/index.php?page=services.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文