Answer the question
In order to leave comments, you need to log in
Why is a redirect set in .htaccess, but the script fires multiple times?
It is necessary that in the subfolder all requests go to index.php. The structure of requests is planned as follows: site.ru/cabinet/show/post/
There is a folder on the site: site.ru/cabinet/. It contains .htaccess:
RewriteEngine on
RewriteBase /cabinet/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^([^.]+[^./])$ $1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} -l
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ [NC,L]
RewriteRule ^.*$ index.php [NC,L]
<html>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<head>
<title>Проверка</title>
<link rel="stylesheet" type="text/css" href="files/screen.css">
<link rel="stylesheet" type="text/css" href="files/main.css">
</head>
<body>
<?
$mailmes="Проверка";
$send_to = "[email protected]";
$subject = "Проверка";
$headers = "From: cabinet <[email protected]> \n";
$headers .= "Content-type: text/html; charset=UTF8\r\n";
$send = mail($send_to, $subject, $mailmes, $headers);
?>
</body>
</html>
RewriteRule ^.*$ [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Answer the question
In order to leave comments, you need to log in
The point is that you are redirecting ALL requests to index.php. In index.php itself, there are links to get css files. Do an analysis in index.php of what is requested and issue the correct file.
----
index.php must start with these lines:
<php
$url = $_SERVER['REQUEST_URI'];
if (strpos($url, "/screen.css" > 0) {
//здесь может потребоваться вывод хэдера для css контента. смотрите на php.net
// тема про хэдер
echo file_get_content($_SERVER['DOCUMENT_ROOT']."files/screen.css");
die();
}
//точно так же повторяем для второго css файла
// для случаев таких файлов вывод прекращается по die()
// для index.php обработка идет дальше
I think it will be useful for you to read once and thoroughly understand how mod_rewrite works:
habrahabr.ru/company/sprinthost/blog/129560
It also says about looping
Refine htaccess:
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
and I would set the paths for css and js from the root of the server and not take out Moscow ....
link rel="stylesheet" type="text/css" href=" / css/screen.css">
In your case, it is better to use the search from Google or Yandex.
https://cse.google.com/
https://site.yandex.ru/
Usually, the search is performed on data from the database, but you, apparently, do not have it.
vista1x is correct. Search becomes on . SELECT * FROM table WHERE title LIKE % keyword%
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question