Download css based on word in url

I would like to be able to upload a separate css file depending on the words in the page url. It is for cms, which has a single index.php, and all the URLs for the pages are generated dynamically.

I would like the URL to contain specific words, then a specific css file should be loaded if the URL does not contain words that another css file should load.

I managed to get him to work with one word, but I can't figure out how to get him to check more words.

The code:

<?php if (stripos($_SERVER['REQUEST_URI'],'/administration/') !== false){$style = "css/style.css";} else {$style = "css/style1.css";}?>

I would be grateful for any help! Thank!

+3
source share
2 answers

I'm not quite sure what you mean. This is my best guess. You need more than 2 conditions:

<?php
if (stripos($_SERVER['REQUEST_URI'],'/administration/') !== false){$style = "css/style.css";}
else if(stripos($_SERVER['REQUEST_URI'],'/member/') !== false) {$style = "css/style2.css";}
else if(stripos($_SERVER['REQUEST_URI'],'/customer/') !== false) {$style = "css/style3.css";}
else {$style = "css/style1.css";}
?>
+2
source

, switch elseif, , , css.

+1

All Articles