Apache 重写引擎不工作[.htaccess]
重写引擎不工作,我正在使用000Webhost作为我的Web托管服务提供商,我正在执行免费计划 问题:Apache 重写引擎不工作[.htaccess],apache,.htaccess,redirect,mod-rewrite,Apache,.htaccess,Redirect,Mod Rewrite,重写引擎不工作,我正在使用000Webhost作为我的Web托管服务提供商,我正在执行免费计划 问题: 1.)当我转到prospekt.ml之类的域(没有子域)时,我将被重定向到000WebHost404错误 2.)当我尝试测试.htaccess是否工作时。它应该重写url并添加一个虚荣url。类似于(user/astroXoom),但不是这样,我被重定向到000Webhost 404错误 .htaccess文件放在我的公共html文件夹中。它应该重定向到“member/user/usernam
1.)当我转到prospekt.ml之类的域(没有子域)时,我将被重定向到000WebHost404错误 2.)当我尝试测试.htaccess是否工作时。它应该重写url并添加一个虚荣url。类似于(user/astroXoom),但不是这样,我被重定向到000Webhost 404错误 .htaccess文件放在我的公共html文件夹中。它应该重定向到“member/user/username.php?username=$1” 我的照片截图 谢谢你,祝你今天愉快 编辑:
这是我的.htaccess文件
在000webhost server上,您必须使用绝对重写路径(以/)或RewriteBase指令将重写的url映射到正确的位置,因为000webhost server使用虚拟用户主目录,因此在rewrite target中使用相对路径时,添加RewriteBase指令非常重要,否则你将得到一个404找不到 资料来源:
尝试在您的重写目标中添加/before成员。将其作为答案发布,以便我现在可以检查它:
RewriteBase/member/user/RewriteEngine on RewriteRule^([^/]+)$profile.php?username=$1[L,QSA]
但它不是静止的working@VirtualAnonREWRITBASE指令应在引擎联机时执行,否则apache不会使用它。编辑了它,但仍然不工作,你能编辑你的答案吗?谢谢:)@VirtualAnon如果profile.php位于public_html文件夹中,那么您需要使用RewriteBase/not/member/user,因为它指向/member/user/profile.php,我认为这是一个错误的目标。profile.php位于member的user文件夹中,因此不在public_html文件夹中。
# Do not remove this line, otherwise mod_rewrite rules will stop working
RewriteBase /
# Fancy Indexing
Options Indexes
IndexOptions FancyIndexing NameWidth=80 ScanHTMLTitles
IndexOrderDefault Ascending Date
IndexIgnore *.jpg *.png
# Rewrite for Users
RewriteEngine on
RewriteRule ^member/user/([^/]+)$ member/user/username.php?username=$1 [L,QSA]