apache - subdomain wildcard .htaccess for escape cloudflare -



apache - subdomain wildcard .htaccess for escape cloudflare -

i have example.com domain , set on cloudflare. time don't need utilize cloudflare, create up.example.com subdomain , unused of cloudflare it. park on main domain. means example.com , up.example.com point root site. cover duplicate content in seo, need .htaccess file.

these items of import me:

all urls under main domain (example.com) must open , accessible. the main page don't open subdomain (up.example.com) , open main domain (example.com). all address upload controller must accessible subdomain. example: up.example.com/upload/ the word after controller (my action) contain a-z, 0-9 (because don't allow utilize dot point file) about urls path must don't accessible subdomain , must 404 error.

for this, write code here:

rewriteengine on rewritecond %{http_host} ^up\..+ [nc] rewritecond %{request_uri} !^(/upload/?[a-z,a-z,0-9]*)$ [nc] rewriterule . - [r=404,l,ns] # hide index.php , used yii php framework rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . index.php [l,qsa]

but in code problem is:

up.example.com => open it! don't must open it. up.example.com/upload/test => me not found. requested url /index.php not found on server. , must open it.

note: urls right 404 error, illustration up.example.com/upload/test.jpg not found. requested url /upload/test.jpg not found on server. error message, in error message pointed /upload/test.jpg up.example.com/upload/test in error message pointed index.php file!

please assist me have correction .htaccess code.

i resolve problem help in this link. must utilize !^index\.php$ instead .

correction code:

rewriteengine on rewritecond %{http_host} ^up\. [nc] rewritecond %{the_request} \s/+index\.php[?\s] [nc] rewriterule ^index\.php$ - [r=404,l,nc] rewritecond %{http_host} ^up\. [nc] rewritecond %{request_uri} !^(/upload/?[a-z,a-z,0-9]*)$ [nc] rewriterule !^index\.php$ - [r=404,l,nc] # hide index.php , used yii php framework rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . index.php [l,qsa]

apache .htaccess subdomain wildcard cloudflare

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -