Is it possible to implement the following in .htaccess ?

If they are accessed from the wap.site.com domain , then the files are taken from the / pages / wap / folder (this option is now implemented)

If they are addressed from the site.com domain, the files are taken from the / pages / web / folder, but if there is no suitable file in the / pages / web / folder, the file is taken from the / pages / wap / folder

New to htaccess and even have no idea how to implement it and whether it is possible. I just made a wap version of the site, and the web is just starting, I want to open it and develop a little bit of the web version of the pages, but for now there are no pages, then let it be with the wap version.

  • More precisely: the first option is implemented, I want to implement the second one. - Andriy Hopta

1 answer 1

try this

 RewriteEngine on RewriteCond %{HTTP_HOST} ^site.com RewriteRule ^(.*)$ /pages/web/$1 [L,NC,QSA] # RewriteCond %{HTTP_HOST} ^wap.site.com # Это можно не учитивать, # так как если нет в папке /pages/web но переводим в /pages/wap/ # если нет это директории RewriteCond %{REQUEST_FILENAME} !-d # если нет этого файла RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /pages/wap/$1 [L,NC,QSA] 
  • one
    Thank! Your code almost worked. I made some adjustments, for redirected to / pages / wap / pages / $ 1. Now this code works fine: RewriteEngine on RewriteCond% {HTTP_HOST} ^ site.com RewriteRule ^ (. *) $ / Pages / web / $ 1 [L, NC, QSA] # if not, this is the RewriteCond% {REQUEST_FILENAME directory!! -D # if there is no this file RewriteCond% {REQUEST_FILENAME}! -f RewriteRule ^ pages /(.*)$ / pages / wap / $ 1 [L, NC, QSA] - Andriy Hopta
  • It turns out in the link you have involved pages/ from this you had to change. agree, thanks - Saidolim