Author |
|
karenwood
Joined: 20 Dec 2014 Posts: 9 Location: USA, Ventura
|
Posted: Sat 20 Dec '14 19:30 Post subject: alias.domain rewrite, redirect or something. |
|
|
Apache version 2.2.14 (ubuntu 10.04)
I need to redirect my domain
<VirtualHost 192.168.1.3:80>
ServerName domain.com
ServerAlias www.domain.com
ServerAlias alias.domain.com
</VirtualHost>
I need to tell the server to redirect from:
http://alias.domain.com
to
http://www.domain.com/shopping
(and/or how would it to 'forward' to a shopping.php page?)
I cannot make it work without endless looping!
KW
|
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Sat 20 Dec '14 23:10 Post subject: |
|
|
Hi,
it is easy to do
Code: | RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
|
|
|
Back to top |
|
karenwood
Joined: 20 Dec 2014 Posts: 9 Location: USA, Ventura
|
Posted: Sun 21 Dec '14 2:23 Post subject: fail |
|
|
RewriteBase: only valid in per-directory config files
...fail!
Thanks but your example is the same as the MANual. (and too hard for me to de-code with any success).
I tried:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^fancyalias\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/shopping/$1 [R=301,L]
Can you please translate more specific to my request, please. I do naught understand the $1
my need:
from:
alias.domain.com
to:
www.domain.com/shopping.php
or:
www.domain.com/shopping/ |
|
Back to top |
|
karenwood
Joined: 20 Dec 2014 Posts: 9 Location: USA, Ventura
|
Posted: Sun 21 Dec '14 23:21 Post subject: Stucked & No Worky |
|
|
Stucked & No Worky |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Mon 22 Dec '14 11:35 Post subject: |
|
|
Code: |
RewriteEngine On
# if the host is NOT (!) www than rewrite the stuff
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com$ [NC]
# get everthing from the URL and append it where the $1 is
RewriteRule ^(.*)$ http://www.mydomain.com/shopping/$1 [R=301,L]
|
|
|
Back to top |
|
karenwood
Joined: 20 Dec 2014 Posts: 9 Location: USA, Ventura
|
Posted: Tue 23 Dec '14 7:16 Post subject: success! |
|
|
I deleted the $1 and it works as I wush.
I still don't know what the $1 is for.
I can do both /shopping with an index.page there, and /shopping.php with much success!
The unknown factor is what that $1 does as it appended two slashes afta shopping//
Love You Apache Boys for rescuing lil ol' me and mine |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
|
Back to top |
|
karenwood
Joined: 20 Dec 2014 Posts: 9 Location: USA, Ventura
|
Posted: Thu 15 Jan '15 23:47 Post subject: working but presents new problem |
|
|
alias.domain.com/shopping/index.php works as I was hoping for expected:
Code: |
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/shopping/index.php [R=301,L] |
BUT I now find that any directory redirects so, domain.com/otherdirectory redirects too! (no www.domain.com or alias.domain.com)
please reply, thank you! |
|
Back to top |
|
karenwood
Joined: 20 Dec 2014 Posts: 9 Location: USA, Ventura
|
Posted: Sat 17 Jan '15 12:34 Post subject: solved one problem -caused another!!! |
|
|
Please help!
Although the domain.com/shopping/index.php works according to the .htaccess directive, now ANY DIRECTORY also reditects!!!
I must ONLY redirect the shopping directory not EVERY directory.
Please respond, thank you!!!!! |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Sat 17 Jan '15 23:11 Post subject: |
|
|
You can put that rewrite rule into a directory block or move the .htaccess file in to the shopping folder |
|
Back to top |
|
karenwood
Joined: 20 Dec 2014 Posts: 9 Location: USA, Ventura
|
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Wed 04 Feb '15 14:13 Post subject: |
|
|
OMG ...you've even got this dumb guy from down the coast confused.
The last line of your last post reads aliasword.karensdomain.com -> aliasword.karensdomain.com/shopping/index.php
Way up above you claim you want aliasword.karensdomain.com -> www.karensdomain.com/shopping/index.php
Which is it?
My other maybe more important question is, if I go to simply www.karensdomain.com where do you want me to land then? This will help me decide if you even really need rewriting.
But let's back up a little and scratch our heads. What you have there says: If the hostname does not match www.karensdomain.com then do stuff. To be honest, I do not think before time ends and only machines roam the earth aliasword.karensdomain.com is ever going to match www.karensdomain.com and probably not even then. What do you think? If you agree, then I suppose that condition needs to be tossed into the La Brea tar pit because the rule then is always going to fire for anything not www.karensdomain.com, you know, like http://aliasword.karensdomain.com/help.
So I think you want to hone in on only aliasword.karensdomain.com instead, but remember, I'm confused!
RewriteCond %{HTTP_HOST} ^aliasword\.karensdomain\.com$ [NC]
of course that still leaves the problem of likely barfing up on things like http://aliasword.karensdomain.com/about and friends so maybe add a caveat after it
RewriteCond %{REQUEST_FILENAME} !-d
I must admit I am not a URL Rewriting wiz though, it's an art form I have not come close to mastering sadly. |
|
Back to top |
|
karenwood
Joined: 20 Dec 2014 Posts: 9 Location: USA, Ventura
|
Posted: Fri 06 Feb '15 22:44 Post subject: |
|
|
need:
www.KARENSDOMAIN.com >>goto index.php
nothing_here_before.KARENSDOMAIN.com/regular_old_index.php page
DumbWord_alias.KARENSDOMAIN.com/Regular_old_INDEX.PAGE.PHP
SPECIALWORD_ALIAS.KARENSDOMOAIN.com/shopping/index.php
pretty please...
Sincerely,
Karen |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Sat 07 Feb '15 11:06 Post subject: |
|
|
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{HTTP_HOST} ^specialword_alias\.karensdomain\.com$ [NC]
RewriteRule .? /shopping/index.php [R=301,L]
Does this not do what you're looking for?
This should not affect
karensdomain.com
www.karensdomain.com
dumbword_alias.karensdomain.com
so all the above should just go to what is set for the DirectoryIndex, which I assume is index.php
It should also not affect
specialword_alias.karensdomain.com/some_other_existing_file_or_folder |
|
Back to top |
|
karenwood
Joined: 20 Dec 2014 Posts: 9 Location: USA, Ventura
|
Posted: Sun 08 Feb '15 5:41 Post subject: successssssssssss! |
|
|
¡muchas gracias!
!thank you mooie muchas!
|
|
Back to top |
|