简体   繁体   中英

Main domain subdomain htaccess

I have a domain called www.abc123.com.

after public_html/, I have a folder called portfolio which runs everything for www.abc123.com

Using this htaccess after public_html/

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteRule ^$ portfolio/index.php [L]
RewriteRule ^(.+)$ $1.html [L,QSA]
RewriteRule ^(.*)\.(\d+)(_m_\d+)?\.([^\.]+)$    $1.$4    [L,QSA]

</IfModule>

So when www.abc123.com is visited it will run portfolio/index.php with a clean url of www.abc123.com .

Now Ive added a subdomain called coolstuff now my file manager looks like this

public_html/
    cgi-bin/
    portfolio/
    coolstuff/index.html

now everytime I go to coolstuff.abc123.com/index.html i get 500 Internal Server Error. If I take out my htaccess then coolstuff.abc123.com/index.html will show and www.abc123.com will show anchor tags of my cgi-bin,portfolio,coolstuff.

I need:

  • www.abc123.com to read portfolio/index.php and keep url (www.abc123.com)
  • and coolstuff.abc123.com/index.html to show

Keep your rules like this:

RewriteEngine On

RewriteCond %{HTTP_HOST} abc123
RewriteRule ^$ portfolio/index.php [L]

RewriteCond %{HTTP_HOST} abc123
RewriteCond %{DOCUMENT_ROOT}/$1\.html -f [NC]
RewriteRule ^(.+?)/?$ $1.html [L,QSA]

RewriteCond %{HTTP_HOST} abc123
RewriteRule ^(.*)\.(\d+)(_m_\d+)?\.([^.]+)$ $1.$4 [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.

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