在虚拟主机中应用mod_rewrite
我想重写虚拟主机中的网址。
虚拟目录:
htdoc/dev/ , dev.com
htdoc/dev 中的 .htaccess 中的语法:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule test.html$ test.php [L]
</IfModule>
我能够在本地主机中将 test.html 重写为 test.php。但是,无法在虚拟主机中执行此操作。这里出了什么问题?
I would like to rewrite url in virtual host.
Virtual directory:
htdoc/dev/ , dev.com
Syntax in .htaccess in htdoc/dev:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule test.html$ test.php [L]
</IfModule>
I am able to rewrite test.html to test.php in localhost. However, not able to do it in virtual host. What went wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请检查您是否将 AllowOverride 选项设置为 All:
Please check that you have AllowOverride option set to All:
需要在 httpd.conf 的目录部分中完成...
...如果使用虚拟主机,您需要添加虚拟主机目录,如下所示...
Needs to be done in httpd.conf in the directory section...
...if using Virtual Hosting, you'd need to add the virtual host directory as in...