|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| IT Discussion Forum Having IT issues? Got IT questions? Who doesn't? If you can't get your Apache to work with your MySQL or your php is choking on your ODBC... Let's see if we can help you come up with some ideas. |
Share Thread: & Tags
|
||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I just changed the DNS to launch a new website and I need a little help. I've done plenty of 301 redirects before for individual files, but how do you do a redirect for an entire folder? Also many of the pages on the old site had urls like 'news.php?id=4" Is it possible to do a redirect for any URL containing 'news.php' id, and a number to the home page?
I appreciate any help. |
|
|||
|
I would try this :
Code:
RedirectPermanent /old_folder/ http://www.new_domain.com/new_folder/ RedirectPermanent /news.php http://www.new_domain.com/? |
|
||||
|
Redirection using .htaccess is quite simple, keep 3 things in mind:
1) Do you have POST variables to these old urls, while posting a variables, it will lose values. 2) Make sure you don't lose the value of links that old urls had but doing proper redirection. 3) Links from internal pages needs to change to new urls as fast as possible to improve user experience. Lets take things one by one: news.php?id=4 , if the new urls in a pattern like something-4.html, it can be done at .htaccess like RewriteRule news.php?id=(.*) /foldername/$1.html [R=301,L] Now if the new URLs doesn't have a pattern RewriteRule news.php?id=(.*) /redirect/index.php?id=$1 [L] Now the redirect/index.php can get the new url from the DB and do a 301 redirection. Folder redirection can happen like RewriteRule ^/oldfolder/(.*) http://domain.tld/newfolder/$1 More matching and complex things can be done with referring variables from condition comparisons. Do let me know if you need more help. Regards, Aji Issac
__________________
Be web educated - Client education series - Let not your SEO company cheat you. When they screw your website, they lose one client and you everything. |
|
||||
|
You may find some help here, (above ^^ notes looks like good tips):-
Apache open-source software and Apache Servers. Mod Rewrite. and .htaccess Files and .htaccess Help. How use to .htaccess |
|
|||
|
Great thanks for the tips guys!
AjiNIMC, I have one question about your suggestion. If I want to do as you suggested with this example: RewriteRule ^/oldfolder/(.*) http://domain.tld/newfolder/$1 what does the '$1' do in this example? Is it a variable of some type? Can I leave it out? Thanks! |
|
|||
|
Also, what if I want to create a catch all for any old pages that follow the news.php?id=* format?
i.e. news.php?id=anything forwards to www.mywebsite.com/news/ |
|
||||
|
Quote:
RewriteRule /(.*)/(.*).html showpage?subject=$1&article=$2 $1 would correspond to the first .* and $2 would correspond to the second.
__________________
The best way to learn anything, is to question everything. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| .htaccess and mod_rewrite | inertia | IT Discussion Forum | 3 | 11-16-2007 09:43 AM |
| How to do a mod_rewrite? | watto | Web Programming Discussion Forum | 2 | 06-02-2007 01:17 PM |
| mod_rewrite | watto | Services for Sale/Hire | 0 | 11-08-2005 08:47 PM |
| I Hate mod_rewrite!!! | icb01co2 | Web Programming Discussion Forum | 1 | 05-18-2005 01:04 AM |
| Alternate to mod_rewrite? | cyberious | Search Engine Optimization Forum | 3 | 05-31-2004 02:25 AM |
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |