【问题标题】:.htaccess not working in Apache EC2 Linux Server.htaccess 在 Apache EC2 Linux 服务器中不起作用
【发布时间】:2015-03-20 07:27:33
【问题描述】:

模式重写开启(检查 info.php 测试 AllowOveride All 在 etc/httpd/conf/httpd.conf 文件中

在 /var/www/html 中插入 .htaccess

RewriteEngine On
 RewriteBase /wordpress/
 RewriteRule ^index\.php$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /wordpress/index.php [L]

(想从主页重定向到wordpress子目录...)

重启 Apache

service httpd restart

但 Apache 主页显示在 ...http://mywpblog.net

请求为http://mywpblog.net/wordpress时的wordpress主页

我错过了什么吗? (EC2/httpd 上的虚拟对象)谢谢

【问题讨论】:

标签: .htaccess amazon-ec2 httpd.conf


【解决方案1】:

错误的 .htaccess ! 应该是(在 /var/www/html 目录中)

<IfModule mod_rewrite.c>

# Turn on rewrites.
 RewriteEngine on

# Don't apply to URLs that go to existing files or folders.
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d

# Only apply to URLs that aren't already under /wp.
 RewriteCond %{REQUEST_URI} !^/wordpress/

# Rewrite all those to insert /wordpress
 RewriteRule ^(.*)$ /wordpress/$1

# Redirect the root folder.
 RewriteCond %{HTTP_HOST} ^(www.)?yodojodo.net$
 RewriteRule ^(/)?$ wordpress/ [L]
 </IfModule>

【讨论】:

    猜你喜欢
    • 2017-06-05
    • 2018-06-09
    • 2010-11-10
    • 1970-01-01
    • 1970-01-01
    • 2014-04-13
    • 2011-06-10
    • 2012-06-24
    • 1970-01-01
    相关资源
    最近更新 更多