Angular 使用.htacces访问文件夹内部

Angular 使用.htacces访问文件夹内部,angular,.htaccess,cpanel,Angular,.htaccess,Cpanel,我的文件夹结构如下:www.testlink.com/angular/dist/My-app。 输入此链接时,我必须访问此文件夹:www.testlink.com/angular 如何使用htaccess?如果使用子域,效果会更好 htaccess配置 Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.html [QSA,L] 将基本url添加到index.h

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


如何使用htaccess?

如果使用子域,效果会更好

htaccess配置

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
将基本url添加到index.html

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

配置apache

<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>

服务器名www.subdomain.example.com
服务器管理员webmaster@localhost
DocumentRoot/path/of/your/目录
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合

如果使用子域,效果会更好

htaccess配置

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
将基本url添加到index.html

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

配置apache

<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>

服务器名www.subdomain.example.com
服务器管理员webmaster@localhost
DocumentRoot/path/of/your/目录
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合

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

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
RewriteRule ^/?angular/dist/my-app(/.*) /angular$1 [QSA,R=301,END]
RewriteRule ^/?angular(/.*) /angular/dist/my-app$1 [QSA,END]

显然,重写模块需要在http服务器内部启用,以便对分布式配置文件(“.htaccess”)进行解释必须为http服务器中的该位置启用。

请共享您为解决问题而编写的htacces文件规则。请共享您为解决问题而编写的htacces文件规则。不起作用。。。。这起作用了
RewriteEngine On#不重写文件RewriteCond%{REQUEST_FILENAME}-f RewriteRule^-[L]#如果设置了ALPHA_用户cookie,则为未压缩文件RewriteCond%{HTTP_cookie}ALPHA_用户[NC]RewriteRule^index.html[L]#重写一切RewriteRule^dist/my app/index.html[L]
抱歉,但这些都是特定于您的设置的详细信息,您在问题中没有提及。所以你几乎不能指望任何人考虑这些…我发布的代码符合您的要求。如果你真的在寻找完全不同的东西,那么这个答案肯定“不适合你”。。。。这起作用了
RewriteEngine On#不重写文件RewriteCond%{REQUEST_FILENAME}-f RewriteRule^-[L]#如果设置了ALPHA_用户cookie,则为未压缩文件RewriteCond%{HTTP_cookie}ALPHA_用户[NC]RewriteRule^index.html[L]#重写一切RewriteRule^dist/my app/index.html[L]
抱歉,但这些都是特定于您的设置的详细信息,您在问题中没有提及。所以你几乎不能指望任何人考虑这些…我发布的代码符合您的要求。如果你真的在寻找完全不同的东西,那么这个答案肯定“不适合你”。