.htaccess 在 Apache EC2 Linux 服务器中不起作用

标签 .htaccess amazon-ec2 httpd.conf

模式重写已开启(使用 info.php 测试进行检查 AllowOveride 全部位于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 错误! 应该是(在/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>

关于.htaccess 在 Apache EC2 Linux 服务器中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28072950/

相关文章:

php - .htaccess - 将 domain.pl/something 重定向到 domain.eu/something-else

java - 如何使用 AWS 运行在 localhost 中运行的 Java 应用程序

amazon-web-services - 描述 EC2 实例 使用 AWS cli 过滤实例名称

c - Apache (ab) : mod_fcgid 4x slower than mod_cgi

apache2 - 无法使用 Apache 服务器访问子目录中的文件

.htaccess - 在多个 .htaccess 文件之间共享数据

.htaccess 保护根文件夹但不保护子文件夹

wordpress - 主目录中的 Htaccess 与子目录冲突

php - 在 apache 网络服务器上使用 Ratchet websocket 库为安全 websocket 配置虚拟主机

spring - 在 Amazon EC2 上部署 Spring 项目