0

I am trying to point a subfolder on my site as a subdomain. for example, i want to turn www.domain.com/test to test.domain.com. I already have some rewrites in htaccess done by developers that we used earlier in the site building process, and I'd like to be able to add this line without interfering with those.

I've tried dozens of answers to this issue i found across the net, but none of them seemed to work and i'm not sure if it's due to my lack of knowledge of this language or if there's a conflict with something else.

The latest lines I tried are:

RewriteCond %{HTTP_HOST} !^www.domain.tv 
RewriteCond %{HTTP_HOST} ([^.]+).domain.tv 
RewriteRule ^(.*)$ /var/www/www.domain.tv/test%1

This is my current htaccess file:

 Options +FollowSymLinks

RewriteEngine On

RewriteBase /

#RewriteCond %{HTTP_HOST} !www\.domain\.tv$ [NC]
#RewriteCond %{HTTP_HOST} ^(.+)\.domain\.tv$ [NC]
#RewriteRule .* index.php?option=com_contushdvideoshare&view=player&Itemid=33 [L]

RewriteCond %{REQUEST_URI} ^/album\/t\/([a-zA-Z0-9]+) [NC]
RewriteRule ^album/t/(.*) index.php?option=com_usermenu&task=directdownload&id=$1&type=one$

RewriteCond %{REQUEST_URI} ^/album\/([a-zA-Z0-9]+) [NC]
RewriteRule ^album/(.*) index.php?option=com_usermenu&task=directdownload&id=$1 [L]


RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]

#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]


RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} (/[^.]*|\.(php|html?|feed|pdf|raw))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]

Can anyone help me here?

2 Answers 2

1

Try:

RewriteCond %{HTTP_HOST} !^www.domain.tv [NC]
RewriteCond %{HTTP_HOST} ([^\.]+).domain.tv [NC]
RewriteRule ^(.*)$ %1/$1 [L]
Sign up to request clarification or add additional context in comments.

5 Comments

Not sure what you wanted - I removed the test from the rule. Try now?
I wanted to point www.domain.tv/test to show and operate as test.domain.tv. i think i might have other lines in the htaccess file that is preventing other subdomains. I appreciate your help!
Thanks for your help, but it still isn't working. i just tried a reidrect after i tried your update and that didn't work. i tried RedirectMatch 301 ^/book/(.*)$ book.example.com/$1
How is it not working? Where is it redirecting to? Can you post the full htaccess file? Can you add logging?
Well, if you place my rules at the top, it will load what appears to be test.example.com from DOCUMENT_ROOT/test - which I assume is what you want. Now you presumably want to prevent the subsequent rules from interfering, so I suggest placing a blank .htaccess in the test folder.
0

Subdomains aren't so easy to set up. You will need to configure your server before. More informations here : Create subdomains on the fly with .htaccess (PHP)

1 Comment

Is there a way to redirect the URL so that I don't have to do allt he configuring? Last time I tried to alter the vhosts and the sites-available files my main site (domain.tv) was affected, it was no longer found.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.