Mlax Wong
Mlax Wong

Reputation: 108

Subdomain point to directory that inside specific directory

i get the source code from Stackoverflow-Using wildcard subdomain on specific directory

original code:

    RewriteEngine on
    RewriteBase /

    RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.domain\.com$ [NC]
    RewriteCond %{REQUEST_URI}::%1 !^/([^/]+).*?::\1
    RewriteRule ^(.*)$ /%1/$1 [L]

it's work properly, but the code above is pointing the directory from root. i want all subdomain point to the directory which is in my "portfolio" directory, so i try modify myself the code

after modify(added "/portfolio"):

    RewriteEngine on
    RewriteBase /

    RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.mlaxproject\.com$ [NC]
    RewriteCond %{REQUEST_URI}::%1 !^/([^/]+).*?::\1
    RewriteRule ^(.*)$ /portfolio/%1/$1 [L]

but it give me "500 -Internal Server Error" ... why? can anybody correct my code?

Thank and sorry for my english.

Upvotes: 1

Views: 203

Answers (1)

Ravi K Thapliyal
Ravi K Thapliyal

Reputation: 51721

You need to add /portfolio to your RewriteCond too.

RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.mlaxproject\.com$ [NC]
RewriteCond %{REQUEST_URI}::%1 !^/portfolio/([^/]+).*?::\1
RewriteRule ^(.*)$ /portfolio/%1/$1 [L]

Upvotes: 1

Related Questions