i'm trying a solution to have something like that:
/dev/base/route.php -> include "/dev/base/mysite/index.php"
for php of course i've no problem using this system , all code is properly working, but for html tags ( such as <img
, <link
etc.. ) i need to redirect the requests to ./dev/base/mysite/
directory.
I'm trying to solve it using htaccess (without changing url bar), using this code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond /mysite/$0 -f
RewriteCond /mysite/$0 -d
RewriteRule ^$ /mysite/$0 [L]
but it doesn't work. ( i'm not very skilled in mod_rewrite )
also, i cannot specify /dev/base/
path statically in htaccess file, it should be solved "automatically" because it can change according to workstation.
so i need something that in pseudo-php code syntax should resemble it:
if ( file_exists(SITE_ROOT_DIR."/mysite/".$request) && !file_exists(SITE_ROOT_DIR."/".$request) )
$url=SITE_ROOT_DIR."/mysite/".$request;
else
$url=SITE_ROOT_DIR."/".$request;
thank you in advance!
Change your code with this:
RewriteBase /dev/base/
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l
## don't do anything
RewriteRule ^ - [L]
RewriteCond %{DOCUMENT_ROOT}/dev/base/mysite/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/dev/base/mysite/$1 -d [OR]
RewriteCond %{DOCUMENT_ROOT}/dev/base/mysite/$1 -l
RewriteRule ^(.*?)/?$ mysite/$1 [L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.