mod_rewrite 的问题

发布于 2024-09-10 09:07:25 字数 886 浏览 0 评论 0原文

我在让 .htaccess 按我想要的方式工作时遇到问题,我想知道是否有人可以阐明这一点。

这是我当前的设置:

我的共享托管站点可以通过 http://www20.a2hosting.com/ 访问~myname/

我希望访问其中的几个子目录。例如 http://www20.a2hosting.com/~myname/subdir/public/ index.php 工作得很好。

现在我试图将对我的子目录/公共的所有调用重定向到我的index.php,并且在这个程度上,我在我的子目录/公共中创建了一个 .htaccess 文件,如下所示:

RewriteEngine on 
RewriteRule ^.*$ index.php

但是,当我将我的浏览器定向到 http://www20.a2hosting.com/~myname/subdir/public / 我收到以下 404 错误:

The requested URL /home/myname/public_html/subdir/public/index.php was not found on this server.

我做错了什么?

多谢!

I have a problem with getting my .htaccess to work like I want and I was wondering if anyone could shed a light on this.

Here is my current setup:

My shared hosting site can be accessed by http://www20.a2hosting.com/~myname/

I have several sub directories inside that I wish to access. For instance
http://www20.a2hosting.com/~myname/subdir/public/index.php works just fine.

Now I'm trying to get all the calls to my subdir/public be re-directed to my index.php and to that extent I've created a .htaccess file in my subdir/public that looks as following:

RewriteEngine on 
RewriteRule ^.*$ index.php

However, when I direct my browser to http://www20.a2hosting.com/~myname/subdir/public/
I get the following 404 Error:

The requested URL /home/myname/public_html/subdir/public/index.php was not found on this server.

What am I doing wrong?

Thanks a lot!

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

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

发布评论

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

评论(1

柠檬 2024-09-17 09:07:25

尝试指定绝对路径作为重写目标:

  RewriteRule ^.*$ /index.php

Try specifying an absolute path as the rewrite target:

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