【问题标题】:Access inside folder with.htacces使用.htaccess 访问文件夹内部
【发布时间】:2020-11-18 06:33:40
【问题描述】:

我的文件夹结构是这样的:www.testlink.com/angular/dist/my-app。 输入此链接时,我必须访问此文件夹:www.testlink.com/angular

如何使用 htaccess?

【问题讨论】:

  • 请在您的问题中分享您为解决此问题而编写的 htacces 文件规则。

标签: angular .htaccess cpanel


【解决方案1】:

如果你使用子域会更好

htaccess 配置

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]

将基本网址添加到 index.html

<base href="http://subdomain.testlink.com/">

配置阿帕奇

<VirtualHost *:80>
    ServerName www.subdomain.example.com
    ServerAdmin webmaster@localhost
    DocumentRoot /path/of/your/directory

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

【讨论】:

    【解决方案2】:

    这可能是您正在寻找的,外部重定向与内部重写的组合:

    RewriteEngine on
    RewriteRule ^/?angular/dist/my-app(/.*) /angular$1 [QSA,R=301,END]
    RewriteRule ^/?angular(/.*) /angular/dist/my-app$1 [QSA,END]
    

    显然需要在 http 服务器内启用重写模块,并且必须在 http 服务器内的该位置启用分布式配置文件(“.htaccess”)的解释。

    【讨论】:

    • 不工作....这工作....RewriteEngine On # Don't rewrite files RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^ - [L] # If the ALPHA_USER cookie is set, serve the uncompressed files RewriteCond %{HTTP_COOKIE} ALPHA_USER [NC] RewriteRule ^ index.html [L] # Rewrite everything RewriteRule ^ dist/my-app/index.html [L]
    • 抱歉,这些是特定于您的设置的详细信息,您在问题中没有提及任何字词。所以你几乎不能指望任何人考虑这些......我发布的代码符合你的要求。如果你真的在寻找完全不同的东西,那么这个答案肯定“不适合你”。
    猜你喜欢
    • 2021-11-26
    • 2014-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-11
    • 1970-01-01
    相关资源
    最近更新 更多