我无法使 RewriteBase 和 RewriteRule 正常工作

发布于 2024-11-09 09:57:10 字数 459 浏览 0 评论 0原文

我的结构如下:

mywebsite/clubeadv/

在该文件夹内,我有一个名为 site.php 的文件,它接收参数 id。

所以,物理路径是:

mywebsite/clubeadv/site.php?id=something

但我希望它看起来像这样:

mywebsite/clubeadv/site/something

(其中“something”是我的参数)

如何配置 . HT访问文件?

我尝试了以下方法:

Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteRule ^site/(.*)$ site.php?id=$1

任何帮助将不胜感激。

谢谢。

My structure is the following:

mywebsite/clubeadv/

Inside that folder I have a file called site.php which receives a parameter id.

So, the physical path would be:

mywebsite/clubeadv/site.php?id=something

But I want it to look like this:

mywebsite/clubeadv/site/something

(where 'something' is my parameter)

HOW DO I CONFIGURE THE .HTACCESS FILE?

I tried the following:

Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteRule ^site/(.*)$ site.php?id=$1

Any help would be appreciated.

Thank you.

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

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

发布评论

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

评论(3

比忠 2024-11-16 09:57:10

尝试删除 RewriteBase 并将 .htaccess 放入“clubeadv”文件夹中。如果您的 .htaccess 位于“mywebsite”文件夹的根目录中,那么您可以保留 RewriteBase 但使用 RewriteRuleclubeadv/site/(.*)$clubeadv/site.php?id=$1

方式,我很确定“^site”会导致它在您的情况下查找 mywebsite/site/something 。

Try removing the RewriteBase and placing the .htaccess inside your "clubeadv" folder. If your .htaccess is at the root within the "mywebsite" folder, then you could lave the RewriteBase but use RewriteRule clubeadv/site/(.*)$ clubeadv/site.php?id=$1

Either way, I'm pretty sure the "^site" causes it to look for mywebsite/site/something in your case.

满身野味 2024-11-16 09:57:10

它看起来像你想要的:

RewriteEngine On
RewriteBase /clubeadv/
RewriteRule . site.php?id=%{REQUEST_URI}

它将把像 www.<>.com/clubeadv/abc/edf 这样的 URL 处理为 site.php?id=/abc/edf。

It looks like you want:

RewriteEngine On
RewriteBase /clubeadv/
RewriteRule . site.php?id=%{REQUEST_URI}

That will handle URLs like www.<>.com/clubeadv/abc/edf as site.php?id=/abc/edf.

动次打次papapa 2024-11-16 09:57:10

显然问题出在服务器配置上。要启用 .htaccess 文件,我们必须:

  • 加载以下模块:

LoadModule rewrite_module module/mod_rewrite.so

  • 在“目录”标签下启用所需网站的覆盖:

    AllowOverride All

感谢那些回答的人。

Apparently the problem was the server configuration. To enable .htaccess files, we had to:

  • Have the following module loaded:

LoadModule rewrite_module modules/mod_rewrite.so

  • Enable override for needed websites under 'directory' tag:

    AllowOverride All

Thank you to those who answered.

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