There is a page.

usluga.php 

On the basis of the transmitted parameter, a page with the description and so on is formed, then this parameter is turned into CNC, in the end the whole thing looks like this

 usluga/nameusl 

And now links and file connections (css / js) do not work on this page.

 <link href="www.sitename.com/css/style.css" type="text/css" rel="stylesheet" media="all"> 

is it possible to do something like this so that the links of the form

 <link href="css/style.css" type="text/css" rel="stylesheet" media="all"> 

worked

If in do instead

 usluga/nameusl usluga-nameusl 

Everything works as it should

.htaccess

 ErrorDocument 404 index.php RewriteEngine on RewriteRule ^usluga/([^/]+)/?$ usluga.php?link=$1 [L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*)$ $1.php RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule ^(.*)$ $1.html <FilesMatch ".(gif|jpg|jpeg|png)$"> Header set Cache-Control "max-age=2592000" </FilesMatch> 
  • There is clearly not enough htacess. - labris
  • @labris, here is added - zkolya
  • I would use $ _SERVER - labris variable for addresses

1 answer 1

The usluga/nameusl is one level further from the host than the usluga page.

So, either you need to put two points and a slash before the CSS address (but then the “simple” usluga page will not work correctly, or

Register the following for the CSS file address:

 <?php echo "http://" . $_SERVER['SERVER_NAME'] . "/css/style.css"; ?> 

Then the address of the CSS file will not depend on the place from which it is called.