重写 Mod 重写

发布于 2024-12-25 07:01:52 字数 424 浏览 3 评论 0原文

所以,我的主机最近宕机了,我不得不搬到一个新的主机 - 但这意味着我的 htaccess 文件在搬迁过程中丢失了......

现在我必须重写它,但这从一开始就是一个冒险。 ..

我需要做的是编写以下内容...

转...

http://longdomain.com/show.php?id=100

http://shortdomain.com/100

因此,当有人访问短网址时,它将加载长网址,而不更改他们所在的实际网址。

这使我的短 URL 服务与帐户和 URL 管理部分分开。

我为此使用了 mod 代理,这样我就可以跨域。

但我对自己是如何做到的感到茫然。

谢谢你们的帮助...

So, my host went down recently and I had to move to a new host - but that means my htaccess file got lost in the move...

And now I've got to rewrite it, but it was a crapshoot to begin with...

What I need to do is write the following...

Turn...

http://longdomain.com/show.php?id=100

into

http://shortdomain.com/100

So when somebody visits the short URL, it'll load the long URL without changing the actual URL they're at.

This keeps my short URL service separate from the account and URL management sections.

I was using mod proxy for this so I could go cross domain.

I'm at a loss as to how I was doing it though.

Thanks for the help guys...

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

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

发布评论

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

评论(1

自由如风 2025-01-01 07:01:52

将以下内容添加到 shortdomain 站点根目录中的 .htaccess

RewriteEngine on
RewriteBase /

#if its on shortdoman
RewriteCond %{HTTP_HOST} ^shortdomain\.com$ [NC]
#with a numeric path, proxy to longdomain and stop processing further rules
RewriteRule ^([0-9]+)$ http://longdomain.com/show.php?id=$1 [P,L]

Add the following to your .htaccess in the root dir of your shortdomain site

RewriteEngine on
RewriteBase /

#if its on shortdoman
RewriteCond %{HTTP_HOST} ^shortdomain\.com$ [NC]
#with a numeric path, proxy to longdomain and stop processing further rules
RewriteRule ^([0-9]+)$ http://longdomain.com/show.php?id=$1 [P,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文