简体   繁体   中英

.htaccess 301 redirecting --> retrieve CSS style sheet from redirected directory

With the help of my .htaccess file, I was able to redirect all requests made on mydomain.com/folder/ or on any of it's subdomains to mydomain.com as follows:

RedirectMatch 301 /folder/(.*) //

However, I happened to ran into a problem. I have a CSS style sheet at mydomain.com/folder/style.css and I want to link it to a HTML file at mydomain.com/file.html , but the HTML fails to recognize and/or open the CSS style sheet. Nevertheless, I know that the file path used to point to the style sheet is correct.

Could anyone possibly point me to the right direction?

Use this rule instead of yours -- it will redirect ALL requests that start with /folder/ EXCEPT /folder/style.css :

RedirectMatch 301 ^/folder/((?!style\.css).*) /

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM