Results 1 to 14 of 14
January 29th, 2008, 09:51 AM #1htaccess help
I need someone to help with an htaccess file for my godaddy hosting.
I want to host different urls in directories of their own, but cannot get the htaccess to work correctly.
January 29th, 2008, 02:52 PM #2
Are you trying to rewrite URL's of the same domain to a virtual directory structure?
ie widgets.com?cat=superwidgets to widgets.com/superwidgets/
Are you trying to host multiple domains in the same server in different directories?
ie widget.com to myweberver.com/usr/widget
Or is it something different all together?
Either way, could you give an example of what you currently have?
January 29th, 2008, 03:15 PM #3
January 29th, 2008, 03:22 PM #4
So, you want to have example.com resolve to mysite.com/example or do you want example.com to resolve to example.com?
Try something like this and see if it does what you want.
Redirect 301 / http://www.mysitename.com/example
If you have cpanel as a control panel you could also park the example.com on mysite.com/example although I think that is frowned upon by SEs and SEOs.
January 29th, 2008, 03:30 PM #5
RewriteRule ^www\.([^.]+)\.widget\.com(.*) /usr/widget$1$2
should do the trick where widget.com is your virtual domain, this will even allow for subdomains on your virtual domain
January 29th, 2008, 03:36 PM #6
January 29th, 2008, 03:40 PM #7Originally Posted by r2pro
I hope this isn't asking too much. Could you break that down? I've tried learning to rewrite from tutorials and always get lost with what is doing what and why.
January 29th, 2008, 04:18 PM #8
The first line simply turns the mod_rewrite module on and needs to be in the file for any url rewriting to be done. I use it often to change long dynamic GET variable strings into "static looking" filenames, for example:
RewriteRule ^([a-zA-Z0-9_]+)-([a-zA-Z0-9]+)-travel-guide.html /travel-guide.html?city=$1&state=$2 [L]
renames /Washington-DC-travel-guide.html to /travel-guide.html?city=washington&state=DC
But back to the original example.
The second line is composed of three parts
1) RewriteRule which is just the command
2) ^www\.([^.]+)\.widget\.com(.*) is the 'needle' so to speak. It instructs apache to look for URL stings that match that regular expression. Every thing is a literal, except for that which is contained in parentheses. You'll notice two parentheses sets.
3)The last part is what the rewrite engine will transform any matches from part 2. It starts off with the literal directory /usr/widget The $1 represents whatever is matched by the first set of parentheses which could be nothing or a subdomain. The $2 matches whatever is found in the, you guessed it, second group of parentheses. Which is the file name requested
So if someone typed in http://www.bolts.widgets.com/aboutus.html the rewrite engine would translate that to
on the local webserver
So generally speaking, you write the structure of what you are looking to rename to, and anyplace something can change (a variable), you enclose it in parentheses and put in the character set your looking to match.
Then you write the second part with the basic structure of what it really is and you plug the variables from the previous part into it.
The following site is good for regex tutorials:
January 29th, 2008, 04:35 PM #9
January 30th, 2008, 10:26 AM #10
January 30th, 2008, 11:16 AM #11
As far as I know rewriting urls have no effect on search engines. It appears to any http client that the rewritten url is genuine.
I can't really say about redirects, as I have never used them for any purpose. I vaguely recall that Google prefers one method of using redirects for some purposes, like changing a domain name of an established site. But I don't recall the specifics. Just google "SEO effect of ".x method and go with something that looks credible : )
February 7th, 2008, 01:35 PM #12
Is there a way to write this with wildcards or will it always need the specifics for each domain/folder?
(I am trying to just host a few sites under an older godaddy account)
So, I ftp into my main site and the structure is like this:
and so on?
February 8th, 2008, 06:59 AM #13
I'm hoping to learn something new here, but i think you will need some dns records such as an "c name" to point a separate domain name to a subfolder.
does godaddy offer the addon domains? if so use their control panel to point things in the right direction.
February 8th, 2008, 09:20 AM #14
Yes you will need to write a new line with the domain and the folder hard coded in for each domain you want to redirect.
The .htaccess rewrite rules get parsed and checked in order that they are written in your file. So if you wrote a regular expression that matched any domain name, then every domain on your server would get rewritten to the first subdirectory you used.
As far as DNS records go, CNAME records are for aliases, if I wanted widgetey.widgets.com to point to www.yourwidgets.com I'd use a CNAME record. But redirecting one domain to another on the same server would not allow you to have different files for all of your domains. widgets.com, widgets1.com, widgets2.com, etc would all point to the same server and the same directory, so your index.html file for widgets.com would also be seen by all other domains visitors.
For what John wants to do, you just use normal A records like you would on any other server.
And as far as addon domains available through various hosting companies, this is basically what they do in order to add on your domain, you just have a point & click interface in your control panel in setting it up.
By womanht in forum Programming / Datafeeds / ToolsReplies: 5Last Post: February 17th, 2011, 09:30 PM
By Kevin in forum Programming / Datafeeds / ToolsReplies: 2Last Post: December 5th, 2006, 09:09 AM
By BrattyKitty in forum Programming / Datafeeds / ToolsReplies: 8Last Post: December 24th, 2004, 03:57 PM