我的结构如下:
mywebsite/clubeadv/
在这个文件夹里,我有一个名为site.php的文件,它接收一个参数id。
因此,物理路径是:
mywebsite/clubeadv/site.php?id=某种
但我希望它看起来像这样:
mywebsite/clubeadv/site/mething
(其中"something"是我的参数)
如何配置.HTACCESS文件?
我尝试了以下方法:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteRule ^site/(.*)$ site.php?id=$1
如有任何帮助,我们将不胜感激。
谢谢。
尝试删除RewriteBase并将.htaccess放在"clubeadv"文件夹中。如果你的.htaccess位于"mywebsite"文件夹的根目录,那么你可以使用RewriteBase,但使用RewriteRule clubeadv/site/(.*)$ clubeadv/site.php?id=$1
不管怎样,我很确定"^site"会导致它在您的情况下查找mywebsite/网站。
看起来你想要:
RewriteEngine On
RewriteBase /clubeadv/
RewriteRule . site.php?id=%{REQUEST_URI}
这将处理类似www.<>的URL。com/clubeadv/abc/edf-as-site.php?id=/abc/edf。
显然问题出在服务器配置上。为了启用.htaccess文件,我们必须:
- 加载以下模块:
LoadModule rewrite_module modules/mod_rewrite.so
-
在"目录"标签下为所需网站启用覆盖:
AllowOverride All
谢谢回答的人。