V
V
Viktor Taran2019-04-03 15:58:41
htaccess
Viktor Taran, 2019-04-03 15:58:41

In mod rewrite what is the correct way to use a subquery?

site in pure html! (burned from the jumulus because the old one and cleaning such sites are already sick of it)
I threw it on a quick .htaccess

RewriteEngine on
RewriteBase /

#убираем инексы как на главнй так и возможные в каталогах.
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} ^(.*)/index\.(html|htm)$
RewriteCond %{REQUEST_METHOD} =GET
RewriteRule ^(.*)$ %1 [NC,L,R]


#удаляем всем остальным 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.html
RewriteRule (.*)\.html$ /$1 [L,R]

#поскольку реально таких урлов нет нужно  как-то отработать
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-F
RewriteRule ^([^.]+)$ $1.html [NC,L]

Everything works until the moment when it comes across
/catalog.html
and
/catalog
Need:
If there is a catalog.html file, run it while saving ural /catalog
With the current configuration, Apache cannot return Mod_rewrite /catalog/.html
has checks with subqueries, moreover, there are as many as 3 of them, and you can even do it through omission of the condition, but there are so few examples that it is impossible to understand the logic at all.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-04-03
@dodo512

Usually mod_dir is enabled, which redirects from /catalogto /catalog/if it's an existing directory. Those. needed DirectorySlash Offnot to be/catalog/.html

DirectoryIndex index.html
DirectorySlash Off

RewriteEngine on
RewriteBase /

RewriteCond %{THE_REQUEST} ^GET\ ([^?]*?)(/index)?\.htm
RewriteRule ^ %1 [L,R,NE]

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question