Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 04-05-2007, 03:18 PM
Pairodime's Avatar
Pairodime Pairodime is offline
Contributing Member
 
Join Date: 12-12-06
Posts: 68
iTrader: 0 / 0%
Some help with .htaccess file and 301 Redirects

I looked over a few .htaccess Redirect tutorials - but I just did not seem to find the solution to what I think should be an easy fix.

I have a Blog installed - and the pages are indexed in search engines with /index.php?category=(value)Itemid=(value)

I am in the process of rebuilding my site. The directory structure is way diferent now. Mainly they are all static index.php pages. Now that I am on a server that has APACHE and .htaccess I want to Map my pages from the existing old site -> to my new static /index.php pages.

Example: http://www.mywebsite.com/website/ind...gory=2Itemid=3
-> www.mywebsite.com/about/(defaulting to index.php)

I am maping this out based on Itemid=(value)
ex: Itemid=3 => /about/
Itemid=4 => /portfolio/

Many thanks for any advice you might have.
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 04-11-2007, 08:54 PM
Arenlor's Avatar
Arenlor Arenlor is offline
Senior Member
 
Join Date: 01-02-07
Location: PA, USA
Posts: 191
iTrader: 0 / 0%
I don't know .htaccess but I know it'd take what I believe is called the rewrite module or something along that line, but it can be done in php through using
PHP Code:
$cat $_GET['category'];
$id $_GET['Itemid'];
if(
$id != '' || $cat != ''){
header("Location:index.php");

That SHOULD work, and I'm sure someone will be along shortly to show you the .htaccess.
 
Reply With Quote
  #3  
Old 04-12-2007, 09:33 AM
exam's Avatar
exam exam is offline
Senior Member
 
Join Date: 04-20-06
Posts: 278
iTrader: 0 / 0%
Are you using Wordpress or another blog software?
 
Reply With Quote
  #4  
Old 04-12-2007, 11:54 AM
Pairodime's Avatar
Pairodime Pairodime is offline
Contributing Member
 
Join Date: 12-12-06
Posts: 68
iTrader: 0 / 0%
"Are you using Wordpress or another blog software?"

- Yeah, I was using Mambo - actually - it is still there, but I want to change all those pages to my new Static pages. I dont mind leaving MAMBO there as long as I can redirect each page to its new page (they have nothing in common ex: new pages are not made from MAMBO).
 
Reply With Quote
  #5  
Old 04-12-2007, 11:57 AM
Pairodime's Avatar
Pairodime Pairodime is offline
Contributing Member
 
Join Date: 12-12-06
Posts: 68
iTrader: 0 / 0%
Quote:
Originally Posted by Arenlor View Post
I don't know .htaccess but I know it'd take what I believe is called the rewrite module or something along that line, but it can be done in php through using
PHP Code:
$cat $_GET['category'];
$id $_GET['Itemid'];
if(
$id != '' || $cat != ''){
header("Location:index.php");

That SHOULD work, and I'm sure someone will be along shortly to show you the .htaccess.
Awesome! - thanks for this tip... That should work out well... I will let you know if it did the job.
 
Reply With Quote
  #6  
Old 04-12-2007, 12:54 PM
Pairodime's Avatar
Pairodime Pairodime is offline
Contributing Member
 
Join Date: 12-12-06
Posts: 68
iTrader: 0 / 0%
Quote:
Originally Posted by Arenlor View Post
I don't know .htaccess but I know it'd take what I believe is called the rewrite module or something along that line, but it can be done in php through using
PHP Code:
$cat $_GET['category'];
$id $_GET['Itemid'];
if(
$id != '' || $cat != ''){
header("Location:index.php");

That SHOULD work, and I'm sure someone will be along shortly to show you the .htaccess.
Thanks again for this tip! - It will work out perfect! I added one small addition in case somebody else came across this post for the same reason:

PHP Code:
$cat $_GET['category'];
$id $_GET['Itemid'];
if(
$id != '' || $cat != ''){
header("HTTP/1.1 301 Moved Permanently");
header("Location:index.php");

For my particular case with MABO on the backend - it made it easier to use this type of map:

PHP Code:
$id $_GET['Itemid'];
if ( 
$id == "7" ) {
    
header("HTTP/1.1 301 Moved Permanently");
    
header("Location:http://www.mywebsite.com/product/");
    exit();

Its not .htaccess - but it does exactly what I wanted.
 
Reply With Quote
  #7  
Old 04-12-2007, 02:46 PM
Arenlor's Avatar
Arenlor Arenlor is offline
Senior Member
 
Join Date: 01-02-07
Location: PA, USA
Posts: 191
iTrader: 0 / 0%
My host doesn't allow .htaccess files, so I've learned that only some things are too hard for PHP, but I'm sure if I spent time I could get those to work too, and I may try doing so soon.
 
Reply With Quote
  #8  
Old 04-12-2007, 03:04 PM
exam's Avatar
exam exam is offline
Senior Member
 
Join Date: 04-20-06
Posts: 278
iTrader: 0 / 0%
To conform to HTTP standards, the Location header should have a space between the Location: and the URL.
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with .htaccess file (www. redirection) projectwealth Domain Name Forum 4 01-09-2008 06:32 AM
Need help with HTACCESS file brandnew Coding Forum 2 12-02-2007 11:13 PM
.htaccess file handling eloquent Coding Forum 6 02-01-2007 02:07 AM
Site Restructure - can I do 600 301 redirects in a .htaccess? bwb SEO Forum 2 09-28-2006 07:24 PM
.htaccess and redirects? Michael Allison Coding Forum 9 01-16-2006 07:06 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 07:08 PM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC