Mac OSX –重定向.htaccess不起作用?

这是.htaccess文件。

/Library/WebServer/Documents/.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mkyong/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mkyong/index.php [L]
</IfModule>

# END WordPress

/etc/apache2/httpd.conf找到Apache配置文件,确保正确配置了以下设置:

1.加载mod_rewrite.so
2.在“ Directory标签中,将“ AllowOverride更新为all (默认为无)

sudo vim /etc/apache2/httpd.conf
# Make sure below module "mod_rewrite.so" is loaded.
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so
#LoadModule perl_module libexec/apache2/mod_perl.so
LoadModule hfs_apple_module libexec/apache2/mod_hfs_apple.so

#...

DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
    #...

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride all

    #...
</Directory>

参考文献

  1. Apache –将URL映射到文件系统位置
  2. Apache HTTP Server教程:.htaccess文件

翻译自: https://mkyong.com/mac/mac-osx-redirect-htaccess-is-not-working/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值