.htaccess - Redirect subdomain to folder

前端 未结 3 1386
孤城傲影
孤城傲影 2020-11-30 06:34

This question has probably been asked for over a thousand times, but I\'ve tried so many scripts, and googled so long while finding nothing, I thought, let\'s just ask.

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 06:56

    Add this to your .htaccess in your web root / directory

    RewriteEngine on
    RewriteBase /
    
    RewriteCond %{HTTP_HOST} ^m\.daltonempire\.nl$ [NC]
    RewriteCond %{REQUEST_URI} !^/m(/|$) [NC]
    RewriteCond %{REQUEST_FILENAME} !-d # not a dir
    RewriteCond %{REQUEST_FILENAME} !-f # not a file
    RewriteRule ^(.*)$ m/$1 [L]
    

    The %{REQUEST_FILENAME} conditions would let you access /exists.php and not rewrite it to /m/exists.php. Remove those two if you want to rewrite even if that may potentially override existing files and directories.

提交回复
热议问题