Subdomain using .htaccess only - apache

I wanted to know if it is possible to implement sub domain in a web application, only using trick in the .htaccess file? That is avoiding the following
editing the hosts file for the subdomain link
adding a vhost config for the same
Your help be deeply appreciated.
Thanks.

This is not possible by only using an apache directives.

You can add a rewrite command that changes a link to a subdomain.

Related

htaccess redirect ip/~folder to /var/zpanel/hostdata/zadmin/public_html/folder folder

I am a newbie in the .htaccess language and I would like to achieve the following thing: When an user types an http://ZPANEL-IP/~Website it will show him the contents of the /var/zpanel/hostdata/zadmin/public_html/Website folder. I tried doing that using RewriteCond, but didn't manage to do it, how can I achieve it, and if I do the code, where should I put it? Into Apache's default htacces or into the zpanel's htaccess configuration file?
Thanks in advance.

Resolving a sub directory to a Heroku app via .htaccess?

I use a Media Temple Grid Service solution for hosting. I currently have a Heroku app which I serve via blog.domain.com using a CNAME record.
I'm trying to have the sub-directory domain.com/blog resolve to the Heroku app instead. I don't want the header to change, so I'm not looking for a redirect I believe.
I've attempted a couple of snippets for .htaccess files which have not worked for me. Can anyone recommend some tips to have this work?
It seems a proxy pass would work from the research I've done, but I can't figure out where or how to set it up given my GS folder structure.
Any help is much appreciated. Thanks in advance.

How to enable urlManager in Yii for virtual directories?

I'm using xampp and tried to put my yii folder and the webapp folder separate from the htdocs directory. I've followed the instructions from here:
http://el.web.id/how-to-add-virtual-directory-alias-on-apache-xampp-165
I was able to run the main page all right, but the other pages just return a not found status. May I know how to fix this? I'm not even sure if the main problem comes from Apache or from Yii. Thanks a lot.
Oh, I get it now. We'd just need to add a rewritebase on the .htaccess file that matches the alias.
RewriteBase /aliasfolder
This is for reference purposes.

htaccess - rewrites/redirects for addon domains?

I am planning to create some addon domains through cPanel, I'm aware that their content can be accessed by visiting addondomain.maindomain.com and maindomain.com/addondomain - this could lead to duplicate content with search engines, amongst other things, so I would like to prevent this if possible.
After some research it seems the best (probably only) option would be to use .htaccess and rewrites so that the addon domain can only be accessed at www.addondomain.com - what is the best way to go about doing this and can I have the .htaccess file within the maindomain.com directory or will I need it for each addon domain I create?
Any help would be much appreciated, thank you :)
RewriteRule ^addonedomain/(.*)$ http://addondomain.maindomain.com/$1
this code will redirect user from maindomain.com/addonedomain directory to addonedomain.maindomain.com !
it's better to put this code in .htaccess file in root of add-on domain!

Problem in apache2 with mod rewrite when setting rules in .conf files instead of .htaccess

Because of weird security policies of my hosting provider I have to define my rewrite rules in /etc/apache2/conf.d/examplesite.conf instead of writing them on an .htaccess on the www folder of that site.
What I'm trying to do is setup a Wordpress Mu server (http://mu.wordpress.org/forums/topic/17349 ) and so far its working on a 50%.
The main blog loads perfectly but other sub blogs (located for example at www.example.com/blog2 ) don't.
I'm guessing the problem is that the rewrite rules behave differently when declared at .conf files for each virtual host instead of using .htaccess files.
Has anybody else had this problem? How can you fix it?
This doesn't sound like a rewrite problem to me but maybe it is. You don't say what the error is when you try to load one of the sub blogs. Perhaps posting up what your rewrite rule is would be helpful. Also would you be able to set up a scenario where you did them in .htaccess files on a localhost or something and seeing if there was a difference?
If pretty permalinks work, then mod_rewrite is enabled, and rewriting URLs to WordPress successfully.
If this is the case, then it's a problem with your MU install.
Did you choose paths over sub-domains during the MU install? If you didn't, but then later switched, that's where the problem is - are you in a position to fresh install?