G
G
Gregory2020-09-04 13:19:36
Apache HTTP Server
Gregory, 2020-09-04 13:19:36

How to correctly generate RewriteCond in hcaccsess for a specific folder?

Good afternoon!
The structure is the following site.com/dbtest
how to make links like site.com/dbtest/someURL - i.e. non-existing folders were
redirected for processing to site.com/dbtest/blog.php

RewriteEngine On
RewriteCond %{dbtest/REQUEST_FILENAME} !-f     #Если файл не существует
RewriteCond %{dbtest/REQUEST_FILENAME} !-d    #И если папка не существует
RewriteRule ^.*$ dbtest/blog.php [QSA,L]


I conjure everything I don’t conjure
And where to add this rule to the main root htaccsess or to htaccsess in the site.com/dbtest/ folder

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
Gennady S, 2020-09-04
@gtomilin

You obviously have something extra: dbtest/REQUEST_FILENAME
Try .htaccess in the dbtest folder (will be for all links from dbtest):

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ blog.php [L]
</IfModule>

D
Dima, 2015-08-13
@CrazyFail

you can use PHP Cookie php.net/manual/ru/function.setcookie.php
or jQuery plugin jQuery.cookie plugins.jquery.com/cookie
And when loading the page, if there is something in the Cookie, then display it in this form

S
Sergey Melnikov, 2015-08-14
@mlnkv

document.cookie = "userName=Vasya";
and if you don't know what to do with it - freelansim.ru

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question