A
A
Alexander Grimashevich2020-04-19 11:15:42
htaccess
Alexander Grimashevich, 2020-04-19 11:15:42

How to set up a redirect to a folder?

Good afternoon.
Happy holiday everyone!

I can’t solve the problem here, but I really need it :(

Input data:
1. There is a site, page caching is configured on it, cache files are html pages that are stored in the page-cache folder.

2. All requests that go to the root /, are first created in the cache and then the page is taken from page-

cache.For example, go here site.com/kiev, the page is automatically pulled from site.com/page-cache/kiev.html Everything is cool, everything works.However, if you type in browser line site.com/page-cache/kiev.html then this page is available :( But I would like it to automatically redirect to site.com/kiev For half a

day I can’t figure out how to set up a redirect. Please help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2020-04-19
@jams

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^page-cache/(.*?)(\.html|$) http://site.com/$1 [R=301,L]

RewriteRule ^$ page-cache/pc__index__pc.html [L]

RewriteCond %{DOCUMENT_ROOT}/page-cache/$1.html -f
RewriteRule (.+) page-cache/$1.html [L]

S
Sergey, 2020-04-19
@KingstonKMS

RewriteCond %{REQUEST_URI} "^/page-cache" [NC]
RewriteRule ^page-cache\/(.*)\.html$ http://site.com/$1 [R=302,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question