简体   繁体   中英

multiple domains with htaccess rewrite rule

I'm having difficulties getting an htaccess to work with a subdomain.
my server structure:

root / index.php ---//codeigniter index file, for application A, main domain points here.
root/staging/StagingWebsite ---// my subdomain is pointing here.
the folder StagingWebsite has a file called temp.html
moving on, my root htaccess file is this :

RewriteEngine on
RewriteCond 
RewriteCond $1 ^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]

Which turns any access to MyDomain/foo to MyDomain/index.php/foo. (without showing the index.php).

The problem:
When I try to access my subdomain/temp.html , I get a 500 internal error .
when I remove my root/.htaccess , it works fine. So it's obviously my htaccess file.

I've figured out the problem is that the root/.htaccess rule is being applied to the subdomain, which breaks everything, But I have no ideahow to sort it out.

I've placed an empty .htaccess file inside the root/staging/StagingWebsite hoping it would just over-write any previous htaccess settings, But that didn't work.

EDIT
I fixed the issue specifically but I don't like the solution.
I added a RewriteCond to only run the rewrite rule for as specific domain.
Is there a way to solve this without specifying a domain?

Create /root/staging/StagingWebsite/.htaccess with this line only:

RewriteEngine on

This will overwrite any parent's rewrite rules.

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