简体   繁体   中英

htaccess access subdomain subfolders

I've created a subdomain blog.example.co.uk to point to a folder /blog in my root directory.. The folder blog has a subfolder /php which contain scripts that talk to my server eg login, logout. This is my current structure;

root --> /blog --> /php

This is the rule that creates my subdomain

### Blog subdomain
RewriteCond %{HTTP_HOST} ^blog\.example\.co.uk$ [NC]
RewriteCond %{REQUEST_URI} !^/blog/ [NC]
RewriteRule ^(.*)$ /blog/$1 [L]

The problem now is that files in /blog folder can't see files in /php. I also get a file not found when I try the below;

http://blog.example.co.uk/php/login.php

How can I expose these files and be able to access them with the link above. I know I have to create a new rule just don't know how.

To access the scripts I have to point to below;

http://blog.example.co.uk/blog/php/login.php

I also want to exclude the php folder from any rewrites, I'm using the below but it doesn't work for the folder;

RewriteRule ^(/blog/php)($|/) - [L]

Try this .htaccss

RewriteEngine on
RewriteCond $1
!^(index\.php|images|robots\.txt|css|js|font|woff|ttf|svg|eot|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM