.htaccess将非www重定向到www,但在子目录中

时间:2018-04-24 09:37:00

标签: .htaccess redirect

我在服务器的根目录中安装了wordpress。然后我在子目录中有一个kohana框架。我想将kohana框架中的任何网址从非www重定向到www。

kohana框架基础的url结构是www.mydomain.com/quotes

我已经尝试过调整之前使用过的标准重定向,但它没有按预期工作。它重定向到www版本,但最后添加了index.php(www.mydomain.com/quotes/index.php)。

编辑:我忘了提及我还需要将其重定向到https。

下面是我的.htaccess文件:

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /quotes

# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]

# 301 redirect to dubdubdub
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/quotes/$1 [R=301,L]

如何让这个工作正常,以便网址重定向到 www.mydomain.com/quotes/ ,而不是 www.mydomain.com/quotes/index.php

0 个答案:

没有答案