R
R
RootDevice2013-12-18 02:20:13
htaccess
RootDevice, 2013-12-18 02:20:13

How to check for the presence of a file using .htaccess?

Community, please help.
It is necessary to build such a rule using .htaccess.
If the requested (via URL) file does not exist at the specified path, but it is in the xxx folder, then return (redirect to it) to the xxx folder, otherwise (when it is not found either at the requested path or in the xxx folder) redirect to index.php
How to combine all this into a working solution - I will not master. Thoughts move in the following direction:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]

If this is not a folder or a file, then redirect to the main one. How to check the requested page in another folder - knowledge was not enough.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
maxaon, 2013-12-18
@maxaon

Maybe RewriteCond /folder/%{REQUEST_FILENAME} -d? And action accordingly.

R
RootDevice, 2013-12-18
@RootDevice

Enlightenment is starting to come. The standard mechanism that maxaon advised works fine from the root of the domain. But it doesn't work from a subfolder, because %{REQUEST_FILENAME} contains the path from the domain root, and not from the current folder in the user's browser.
And for the request
mysite.ru/workdir/xxx/1.html
with the current workdir directory, the value of the
REQUEST_FILENAME variable is equal to workdir/xxx/1.html
But in order for the request to be processed correctly, REQUEST_FILENAME must be equal to 1.html Using the AcceptPathInfo OFF directive did not give anything .
PS. Under the current directory we mean the one in which htaccess lies.

A
Arman, 2015-01-20
@mk320

If the button does not come with ajax response

var page = 1;
var per_page = 20;

jribbble.getShotsByList('popular', callback, {page: page, per_page: per_page});

$('.btn_p').click(function(){
    jribbble.getShotsByList('popular', callback, {page: ++page, per_page: per_page});
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question