我的子目录重定向有问题。我有这样的项目结构:
在这个结构中,我有一个app,它位于public_html/public/app中,它的url是这样的:www.example.com/app和我有登陆页dir,url是www.example.com。我使用httpd配置将根目录从public_html移动到public_html/public和htaccess文件,将所有内容从landing移动到root dir。
我的主要问题是.htaccess文件部分工作,它在根目录中显示来自登陆页的内容,但也显示url:Www.example.com/page page中的内容,并生成重复的内容。
.htaccess
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/landing-page
RewriteRule ^(.*)$ /landing-page/$1 [NC,L]像这样使用重定向:
Redirect /landing-page/ https://example.com/导致无限循环
发布于 2022-08-16 08:44:19
假设DocumentRoot已设置为public_html/public,则可以在public/目录中尝试该.htaccess:
RewriteEngine on
# external redirect to remove landing-page from external URLs
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^landing-page/(.*) /$1 [R=301,NC,L,NE]
# internal rewrite to add landing-page silently
RewriteRule !^landing-page/ landing-page%{REQUEST_URI} [NC,L]https://stackoverflow.com/questions/73371020
复制相似问题