[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 07-13-2008, 07:38 AM   #1 (permalink)
Senior Member
 
John Doe's Avatar
 
Join Date: Sep 2007
Posts: 1,633
167.05 NP$ (Donate)

John Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to behold


Help! Help with .htaccess 301 redirect

Hi guys,

I need a little help from programming gurus here. My CMS produces URL-s like

mydomain.com/?lang=1
mydomain.com/index.php?lang=1
myaliasdomain.com/?lang=1
myaliasdomain.com/index.php?lang=1

I need to forward all of them to homepage mydomain.com/
My .htaccess includes following code

RewriteCond %{THE_REQUEST} lang=1
RewriteRule . http: // www. mydomain. com? [R=301,L]

it works perfectly for

mydomain.com/index.php?lang=1
myaliasdomain.com/index.php?lang=1

but does not redirect URL without index.php in it. What code should I use to redirect

mydomain.com/?lang=1 and myaliasdomain.com/?lang=1 as well?

Thanks a lot!
__________________
Domain registration - Why pay more?

John Doe is offline  
Old 07-13-2008, 03:00 PM   #2 (permalink)
Senior Member
 
John Doe's Avatar
 
Join Date: Sep 2007
Posts: 1,633
167.05 NP$ (Donate)

John Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to behold


Bumpy, anyone?
__________________
Domain registration - Why pay more?

John Doe is offline  
Old 07-14-2008, 12:59 AM   #3 (permalink)
Senior Member
 
John Doe's Avatar
 
Join Date: Sep 2007
Posts: 1,633
167.05 NP$ (Donate)

John Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to behold


Any help appreciated!
__________________
Domain registration - Why pay more?

John Doe is offline  
Old 07-14-2008, 06:29 AM   #4 (permalink)
Senior Member
 
shockie's Avatar
 
Join Date: Dec 2006
Posts: 4,478
1,025.10 NP$ (Donate)

shockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond repute


try this:

Code:
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} .
RewriteRule ^index.php /index.php [L]
shockie is offline  
Old 07-14-2008, 01:52 PM   #5 (permalink)
Senior Member
 
John Doe's Avatar
 
Join Date: Sep 2007
Posts: 1,633
167.05 NP$ (Donate)

John Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to behold


Thanks Shockie,
Doesn`t this code redirect all URLs that include index.php to /index.php?
__________________
Domain registration - Why pay more?

John Doe is offline  
Old 07-14-2008, 02:27 PM   #6 (permalink)
Senior Member
 
shockie's Avatar
 
Join Date: Dec 2006
Posts: 4,478
1,025.10 NP$ (Donate)

shockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond repute


i think it's supposed to check if anything comes after the "?" and if something does comes after it (i.e., lang=1) then it will take out the lang=1 or whatever else and redirect to index.php.

..... i think... try it out first, lol.
shockie is offline  
Old 07-14-2008, 02:59 PM   #7 (permalink)
Senior Member
 
John Doe's Avatar
 
Join Date: Sep 2007
Posts: 1,633
167.05 NP$ (Donate)

John Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to behold


Quote:
Originally Posted by shockie
i think it's supposed to check if anything comes after the "?" and if something does comes after it (i.e., lang=1) then it will take out the lang=1 or whatever else and redirect to index.php.

..... i think... try it out first, lol.
Is it possible to define lang=1 somewhere in this commandline? I`m sure otherwise all my pages and all languages will be redirected to index.php (they have lang=2, id=100 etc after "?")...
__________________
Domain registration - Why pay more?

John Doe is offline  
Old 07-14-2008, 03:11 PM   #8 (permalink)
Senior Member
 
shockie's Avatar
 
Join Date: Dec 2006
Posts: 4,478
1,025.10 NP$ (Donate)

shockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond reputeshockie has a reputation beyond repute


mmm... if you want it to only apply to index.php and lang=1, could you just append the index.php so that you redirect mydomain.com/ to mydomain.com/index.php with this?

Code:
DirectoryIndex index.php
shockie is offline  
Old 07-14-2008, 03:29 PM   #9 (permalink)
Senior Member
 
John Doe's Avatar
 
Join Date: Sep 2007
Posts: 1,633
167.05 NP$ (Donate)

John Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to beholdJohn Doe is a splendid one to behold


I have actually working redirection for all URLs I need except mydomain.com/?lang=1 and mydomain.com/?lang=2

mydomain.com/index.php?lang=1, mydomain.com/index.php?id=1 etc are redirected properly
__________________
Domain registration - Why pay more?

John Doe is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 02:06 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85