User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » htaccess/javascript URL and redirect Page [1]  
quagmire02
All American
44225 Posts
user info
edit post

i'm sure this is simple, but my head is being stupid today

i have a site with two domains - if you use one domain (d1, the address of that folder on the server), the SSIs don't work, but if you use the other domain (d2, which is really a symlink to the folder on the server), they work just fine...i have no control over the server, so there's nothing i can tweak there...i tried using an .htaccess redirect any requests for d1 to d2, but that either kills it or simply does nothing or generates a redirect loop...i've tried (each individually, of course, and with some minor variations on each):

redirect / http://www.new.com/

redirect http://www.old.com/ http://www.new.com/

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.new.com/$1 [R=301,L]

RewriteEngine on
RewriteRule ^index.html$ http://www.new.com/


but nothing works...i have no ability to tweak the server or the destination of the domain (yet)...in the meantime, i'd like for every time someone tries to access http://www.old.com/, it automatically redirects them to http://www.new.com/...but because they point to the same place, i can't utilize .htaccess because it will affect the correct domain as well

so i was thinking that, for now, the best bet might be to use javascript to check the URL and if it's d1, then to redirect the page to d2...i don't know off the top of my head how to do that

if any of this doesn't make sense (and it might not), i'll try to fill in the blanks

1/5/2009 10:11:06 AM

mellocj
All American
1872 Posts
user info
edit post

try this

Quote :
"
RewriteCond %{HTTP_HOST} ^http://www.old.com [NC]
RewriteCond %{HTTP_HOST} ^old.com [NC]
RewriteRule ^(.*)$ http://www.new.com/$1 [L,R=301]
"

1/5/2009 10:18:27 AM

quagmire02
All American
44225 Posts
user info
edit post

^ nothing happens...it doesn't break anything, but nothing actually changes

1/5/2009 10:32:17 AM

mellocj
All American
1872 Posts
user info
edit post

i should have tested it first.. try this and see if it redirects http://www.old.com

Quote :
"
RewriteCond %{HTTP_HOST} ^http://www.old.com [NC]
RewriteRule ^(.*)$ http://www.new.com/$1 [L,R=301]
"

1/5/2009 10:41:56 AM

quagmire02
All American
44225 Posts
user info
edit post

^ still doesn't do anything

1/5/2009 11:00:17 AM

DPK
All American
2390 Posts
user info
edit post

Try this:
Quote :
"Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^http://www.old.com [NC]
RewriteRule ^(.*)$ http://www.new.com/$1 [L,R=301]"



Or if you have access to your apache/server/error logs, look in it to see what rewrite is doing.

[Edited on January 5, 2009 at 11:34 AM. Reason : htaccess can be a bitch sometimes]

1/5/2009 11:25:25 AM

quagmire02
All American
44225 Posts
user info
edit post

^ that one gave me an "internal server error"...i'm kinda glad to know this isn't super simple, because then i'd feel dumb...at the same time, i want it to work

thanks for all of the suggestions thus far

1/5/2009 12:34:33 PM

DPK
All American
2390 Posts
user info
edit post

Try this now, lol:
Quote :
"Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(http://)(www\.)old.com(/) [NC]
RewriteRule ^(http://)(www\.)old.com(.*)$ http://www.new.com$3 [R=301,L]"


Make sure it's the first thing in your .htaccess and that you have the right permissions on it.

[Edited on January 6, 2009 at 3:51 PM. Reason : Damnit this one has to work, lol.]

1/6/2009 3:40:43 PM

BobbyDigital
Thots and Prayers
41777 Posts
user info
edit post

bump

7/6/2010 9:50:30 PM

quagmire02
All American
44225 Posts
user info
edit post

thxu

okay, more of me sucking at mod_rewrite

so let's say i have a URL string:

http://www.mysite.com/?month=5&day=10&type=icecream
i want it to turn it into:
http://www.mysite.com/5/10/icecream
i'm sure this is easy, but for some reason it doesn't seem to be working for me...also, month, day, and type could be numbers or letters

i've tried:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^?month=([a-zA-Z0-9]+)&day=([a-zA-Z0-9]+)&type=([a-zA-Z0-9]+)$ $1/$2/$3/ [L]
and
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^(?month=[a-zA-Z0-9]+)(&day=[a-zA-Z0-9]+)(&type=[a-zA-Z0-9]+)$ $1/$2/$3/ [L]
but neither works...i'm sure it's something simple that i'm missing, but i'm tired of looking at it

7/6/2010 9:51:21 PM

kiljadn
All American
44690 Posts
user info
edit post

lemme guess, you're doing this with joomla

7/6/2010 10:08:40 PM

Ernie
All American
45943 Posts
user info
edit post

gross, joomla

I know Google links are for dbags, but there are seriously a million resources out there for this

http://www.google.com/search?q=seo+friendly+urls+htaccess

7/6/2010 10:32:26 PM

quagmire02
All American
44225 Posts
user info
edit post

no, not joomla...i've never used joomla

yeah, i can google as well as most others, but i'm still making bupkiss...i figure there's something tiny i'm missing, so i was hoping someone with more experience than i might be able to take a look at and point it out to me

7/7/2010 6:47:48 AM

Stein
All American
19842 Posts
user info
edit post

If you'd doing it on the servers I think you're doing it on, mod_rewrite is disabled.

7/7/2010 10:33:58 AM

quagmire02
All American
44225 Posts
user info
edit post

^ dreamhost?

[Edited on July 7, 2010 at 10:39 AM. Reason : .]

7/7/2010 10:39:47 AM

mellocj
All American
1872 Posts
user info
edit post

^^^^^^ what you're trying to do doesn't really make sense to me -- are you sure you don't want the opposite of what you said? i.e. use mod_rewrite to turn the friendly url into /index.php?bla=1&ble=2 etc

7/7/2010 10:49:55 AM

quagmire02
All American
44225 Posts
user info
edit post

^ yeah, i'm sure i know what i want to do

the URLs are currently "ugly" (&month=5&day=10&type=icecream) and i want to make them "pretty" (5/10/icecream)

7/7/2010 10:53:17 AM

Stein
All American
19842 Posts
user info
edit post

^^^ CoE webservers.

7/7/2010 11:15:55 AM

quagmire02
All American
44225 Posts
user info
edit post

nope, definitely dreamhost

anyone with dreamhost know if there might be something that's keeping me from doing the mod_rewrite (assuming what i've got up there is correct, i mean)

7/7/2010 11:20:27 AM

Novicane
All American
15416 Posts
user info
edit post

http://wiki.dreamhost.com/Mod_rewrite

7/7/2010 11:26:41 AM

quagmire02
All American
44225 Posts
user info
edit post

^ not quite what i was looking for, but a linked page gave me this:

Quote :
"You can use the ampersand character in the target redirect however without some special running gear you can not use an ampersand in the source URL. Definitely inconvenient!"

7/7/2010 1:13:32 PM

 Message Boards » Tech Talk » htaccess/javascript URL and redirect Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.39 - our disclaimer.