【发布时间】:2021-10-24 18:33:36
【问题描述】:
感谢任何可以花点时间查看此内容的人。
最近我在我的网站中创建了一个新部分“子域”,在这个新文件夹中,我包含了一个 Joomla CMS 安装,网址如下所示:http://www.example.com/subdomain/
在这个文件夹中,我添加了一个 htaccess 文件。
## No directory listings
# Redirect non-www to www:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
当我尝试访问说 http://example.com/subdomain/anytrailingstring 时,它并没有像我预期的那样将我重定向到 http://www.example.com/subdomain/anytrailingstring,而是重定向到 http://www.example.com/anytrailingstring 忽略 /subdomain/ 这当然是一个不存在的页面,因此404。
这是个问题。
除此之外,我在根 .htacces 文件中没有任何指令:
DirectoryIndex index.php
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
也许有人可以看到为什么子域 htaccess 没有正确重定向吗?我错过了什么吗?
我根本不擅长 htaccess,如果有人可以帮助我,我将不胜感激。 谢谢!
【问题讨论】:
标签: regex apache .htaccess mod-rewrite url-rewriting