NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Help with .htaccess 301 redirect

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

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 07-13-2008, 08:38 AM THREAD STARTER               #1 (permalink)
Senior Member
 
John Doe's Avatar
Join Date: Sep 2007
Posts: 1,632
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]

????: NamePros.com http://www.namepros.com/programming/492252-help-with-htaccess-301-redirect.html
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, 04:00 PM THREAD STARTER               #2 (permalink)
Senior Member
 
John Doe's Avatar
Join Date: Sep 2007
Posts: 1,632
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, 01:59 AM THREAD STARTER               #3 (permalink)
Senior Member
 
John Doe's Avatar
Join Date: Sep 2007
Posts: 1,632
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, 07:29 AM   #4 (permalink)
Senior Member
 
shockie's Avatar
Join Date: Dec 2006
Posts: 4,702
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
shockie is offline  
Old 07-14-2008, 02:52 PM THREAD STARTER               #5 (permalink)
Senior Member
 
John Doe's Avatar
Join Date: Sep 2007
Posts: 1,632
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, 03:27 PM   #6 (permalink)
Senior Member
 
shockie's Avatar
Join Date: Dec 2006
Posts: 4,702
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
shockie is offline  
Old 07-14-2008, 03:59 PM THREAD STARTER               #7 (permalink)
Senior Member
 
John Doe's Avatar
Join Date: Sep 2007
Posts: 1,632
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
 



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, 04:11 PM   #8 (permalink)
Senior Member
 
shockie's Avatar
Join Date: Dec 2006
Posts: 4,702
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
shockie is offline  
Old 07-14-2008, 04:29 PM THREAD STARTER               #9 (permalink)
Senior Member
 
John Doe's Avatar
Join Date: Sep 2007
Posts: 1,632
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


Liquid Web Smart Servers  
All times are GMT -7. The time now is 06:20 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger