Return to iWEBTOOL

Go Back   iWEBTOOL Talk > The Web and your Website > Programming > PHP
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
Welcome to iWEBTOOL Talk, where you talk about webmaster-related stuff.
 
Discuss topics which interest you.
With over thousands of threads (topics), we're sure you'll find something that'll interest you.
Ask for help whenever you need it.
We have thousands of members who are available to help you if you need it.
It's absolutely FREE!

 1  Register           2  Browse the board           3  Discuss whatever may interest you!
 


Reply
 
Thread Tools Search this Thread Display Modes
Old 05-16-2008, 03:28 PM   #1
jperezmt
Junior Member
 
jperezmt's Avatar
 
Join Date: Apr 2007
Posts: 97
jperezmt is on a distinguished road
Default Mod Rewrite and rewriteCond

I'm trying to make friendly urls for my site but I'm having some issues. I looked at a bunch of tutorials for mod rewrite and .htaccess and I got far enough where it works but I'm having trouble getting rid of the old links.

The address is www.thesite.com/blog.php?id=34

I got the mod rewrite to display it as

www.thesite.com/blog34/PHP/TITLEOFBLOG.htm

Code:
Options +FollowSymLinks RewriteEngine On RewriteRule ^blog([0-9A-Za-z]+)/([0-9A-Za-z]+)/([0-9A-Za-z]+).htm$ blog.php?id=$1&category=$2&title=$3 [L]

But I'm trying to eleminate duplicate content and get redirect the blog.php?id=34 to the new URL

Here is my code

Code:
RewriteCond %{QUERY_STRING} ^id=([0-9]+) RewriteRule ^blog\.php /blog%1/%2/%3.htm? [R=301,L]

So the %2 and %3 don't exist in the redirect so I'm getting
www.thesite.com/blog34//.htm

How can I redirect the old URLS with only the ID to the new ones that list the category and title?

Also, is it possible to just get rid of the ID number so I can have the same content display with just text?

Thanks!!!!
__________________
Build Your Web Presence
jperezmt is offline   Reply With Quote
 
This is an Ad Revenue Sharing forum Place your advert here
SEO Checklist
Get yourself better ranking with
our "Do-it-Yourself" SEO Checklist.
Click Here
Old 05-16-2008, 04:34 PM   #2
rightinpoint
Smurf
 
rightinpoint's Avatar
 
Join Date: May 2008
Posts: 25
rightinpoint is on a distinguished road
Default Re: Mod Rewrite and rewriteCond

well. You can't do it using mod_rewrite, because you do not have page titles in it.

the simplest way - do redirect directly from php. Like such one
Code:
$page = mysql_fetch_assoc(mysql_query("SELECT * FROM pages WHERE id=".$_GET["id]); $new_location = $page["title"]."/".$page["category"].".html"; header ('HTTP/1.1 301 Moved Permanently'); header("Location: ".$new_location); die();
rightinpoint is offline   Reply With Quote
Old 05-16-2008, 04:50 PM   #3
jperezmt
Junior Member
 
jperezmt's Avatar
 
Join Date: Apr 2007
Posts: 97
jperezmt is on a distinguished road
Default Re: Mod Rewrite and rewriteCond

I just tried that and I keep getting this error:

Warning: Cannot modify header information - headers already sent by (...) in ...on line 11

Warning: Cannot modify header information - headers already sent by (... in ... on line 12
__________________
Build Your Web Presence
jperezmt is offline   Reply With Quote
 
This is an Ad Revenue Sharing forum Place your advert here
Webmaster Tools Webmaster Tools Click Here
Reply



Quick Reply
Message:

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

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Expired and expiring domains that have PR and backlinks Domdat Domain Name 5 02-09-2008 01:13 AM
My mod made it :) UnKnown General Talk 5 01-20-2007 01:16 PM
free phpbb forum and mod installation MintyFresh PHP 6 01-14-2007 02:54 PM
My first smf mod! UnKnown General Talk 9 12-10-2006 04:16 PM
Add Your Casino and Bingo and Gambling Links now linkpro Links for Sale 0 10-13-2006 11:13 PM


All times are GMT. The time now is 08:35 AM.


Powered by vBulletin v3.6.7 © 2008, Jelsoft Enterprises Ltd. SEO by vBSEO © 2006, Crawlability, Inc.