我无法使 RewriteBase 和 RewriteRule 正常工作
我的结构如下:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试删除 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.
它看起来像你想要的:
它将把像 www.<>.com/clubeadv/abc/edf 这样的 URL 处理为 site.php?id=/abc/edf。
It looks like you want:
That will handle URLs like www.<>.com/clubeadv/abc/edf as site.php?id=/abc/edf.
显然问题出在服务器配置上。要启用 .htaccess 文件,我们必须:
LoadModule rewrite_module module/mod_rewrite.so
在“目录”标签下启用所需网站的覆盖:
AllowOverride All
感谢那些回答的人。
Apparently the problem was the server configuration. To enable .htaccess files, we had to:
LoadModule rewrite_module modules/mod_rewrite.so
Enable override for needed websites under 'directory' tag:
AllowOverride All
Thank you to those who answered.