.htaccess相同单词的重写规则
.htaccess相同单词的重写规则,.htaccess,mod-rewrite,url-rewriting,.htaccess,Mod Rewrite,Url Rewriting,我有两条导致问题的规则: RewriteRule ^posts$ posts.php RewriteRule ^posts/create$ postscreate.php 我知道我可以使用“post/create”,但这只是两条规则,因为更多的规则都有相同的问题 我在localhost(XAMPP)上完美地使用了这些规则 但是,一旦我将文件移动到宿主并访问“sub.domain.com/posts/create”,它就会将我重定向到posts.php而不是postscreate.php 为什么
我有两条导致问题的规则:
RewriteRule ^posts$ posts.php
RewriteRule ^posts/create$ postscreate.php
我知道我可以使用“post/create”,但这只是两条规则,因为更多的规则都有相同的问题
我在localhost(XAMPP)上完美地使用了这些规则
但是,一旦我将文件移动到宿主并访问“sub.domain.com/posts/create”,它就会将我重定向到posts.php而不是postscreate.php
为什么它在本地主机上运行良好,但在我的主机上却不行?我怎样才能修好它
我的完整.htaccess如下所示(只有两条规则):
localhost上的.htaccess与https规则完全相同。我也在我的主机上尝试了没有https规则的.htaccess,但仍然不起作用
为什么它在本地主机上运行良好,但在我的主机上却不行?我怎样才能修好它
这很可能是由于选项多视图
在主机上打开,但在本地主机上关闭
要禁用此功能,请在.htaccess上使用此行:
Options -MultiViews
选项MultiViews
(请参阅)由Apache的内容协商模块使用,该模块在mod_rewrite
之前运行,并使Apache服务器匹配文件扩展名。因此,如果/file
是URL,那么Apache将提供/file.html
Options -MultiViews