mod_rewrite +访问

发布于 2024-10-04 01:01:46 字数 407 浏览 0 评论 0原文

我有一个 (Joomla) 站点当前未指向域,但直接位于我的服务器 IP 上(即: http ://176.158.165.1/~sitename

每当我尝试测试 mod_rewrite 时,都会收到 404 错误。我已经在同一服务器上的另一个站点上进行了测试,但它可以 100% 工作。这个问题是否是由于直接链接到 IP 地址造成的?

我的 .htaccess 文件如下:

RewriteEngine On
Options +FollowSymLinks
Redirect /google.html http://www.google.com

谢谢,

Dev

I have a (Joomla) site that is not currently pointing to a domain, but is sitting directly on my server IP (i.e.: http://176.158.165.1/~sitename)

Whenever I try to test my mod_rewrite, I get 404 errors. I have tested on another site on the same server, but it works 100%. Could this problem be due to the direct link to the IP address?

My .htaccess file is as follows:

RewriteEngine On
Options +FollowSymLinks
Redirect /google.html http://www.google.com

Thanks,

Dev

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

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

发布评论

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

评论(2

老旧海报 2024-10-11 01:01:46

尝试:

Redirect 301 /google.html http://www.google.com

尝试 #2:(使用 mod_rewrite)

RewriteRule ^google\.html$ http://www.google.com [R=301,NC,L]

try:

Redirect 301 /google.html http://www.google.com

Try #2: (using mod_rewrite)

RewriteRule ^google\.html$ http://www.google.com [R=301,NC,L]
初熏 2024-10-11 01:01:46

在子目录中工作时,无论 htaccess 文件放置在哪里,您都需要添加目录名称:

Redirect /~sitename/google.html http://www.google.com

您也可以使用 RewriteBase 但说实话,我从来没有真正弄清楚如何让它工作,而我却懒得去整理它。

When working in a subdirectory, you need to add the directory name regardless where the htaccess file is placed:

Redirect /~sitename/google.html http://www.google.com

you can also use RewriteBase but to be totally honest, I never really figured out how to get that working, and I've been too lazy to sort it out.

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