Irish SEO,  Marketing & Webmaster Discussion

 

.ht file

This is a discussion on .ht file within the Coding Help forums, part of the Webmaster Help category; Below is what i have in my .ht file, the first rewrite works fine but the second wont work at ...


Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Coding Help

Register Forum Rules FAQDonate Members List Calendar Search Today's Posts Mark Forums Read


Notices

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 17-08-2007, 11:51 PM
ziycon's Avatar
Wannabe Geek
 
Join Date: Jan 2007
Location: Dublin
Posts: 410
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ziycon will become famous soon enough
Send a message via MSN to ziycon Send a message via Skype™ to ziycon
Default .ht file

Below is what i have in my .ht file, the first rewrite works fine but the second wont work at all!, am i missing something?
Code:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /

RewriteRule ^news-([^/]*)\.htm$ /news.php?page=$1 [L]
RewriteRule ^news-topic-([^/]*)\.htm$ /news_topic.php?topic=$1 [L]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 18-08-2007, 01:40 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,048
Nominated 5 Times in 3 Posts
Nominated TOTW/F/M Award(s): 1
louie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enough
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

try adding NC as well after the L
Code:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
 
#move this first
RewriteRule ^news-topic-(.*)\.(htm|html|php)$ /news_topic.php?topic=$1 [L,NC]
#above as it starts with the same ^news-
 
RewriteRule ^news-([^/]*)\.(htm|html|php)$ /news.php?page=$1 [L,NC]
#what do you expect here: -([^/]*) - numbers or letters?
#if number you can try this: -([0-9]+)
the start should be unique for better reference to what you want

I will start the first one with "topic-news" and second to just "news"
__________________
:. Web Design & Development Web Design Ireland
:. Search Engines Optimization Search Engines Optimization
:. Directory Submission Directory Submission
:. News & Press Release Ireland GiveItSocks.com
:. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories
:. I Have 2 Find It Directory SEF Directory

Last edited by louie; 18-08-2007 at 01:44 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 18-08-2007, 04:35 PM
ziycon's Avatar
Wannabe Geek
 
Join Date: Jan 2007
Location: Dublin
Posts: 410
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ziycon will become famous soon enough
Send a message via MSN to ziycon Send a message via Skype™ to ziycon
Default

Quote:
Originally Posted by louie View Post
try adding NC as well after the L
Code:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
 
#move this first
RewriteRule ^news-topic-(.*)\.(htm|html|php)$ /news_topic.php?topic=$1 [L,NC]
#above as it starts with the same ^news-
 
RewriteRule ^news-([^/]*)\.(htm|html|php)$ /news.php?page=$1 [L,NC]
#what do you expect here: -([^/]*) - numbers or letters?
#if number you can try this: -([0-9]+)
the start should be unique for better reference to what you want

I will start the first one with "topic-news" and second to just "news"
Thanks louie, i just changed the second one to "topic-news", thanks again!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 18-08-2007, 04:42 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,048
Nominated 5 Times in 3 Posts
Nominated TOTW/F/M Award(s): 1
louie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enough
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

no probs. you are welcome.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 22-08-2007, 09:45 PM
ziycon's Avatar
Wannabe Geek
 
Join Date: Jan 2007
Location: Dublin
Posts: 410
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ziycon will become famous soon enough
Send a message via MSN to ziycon Send a message via Skype™ to ziycon
Default

louie, not sure if you can help me again, i have all the rule rewriting working and all now so i want to fancy it up a bit.

This is what i have:
Code:
RewriteRule ^article/([^/]*)\.htm$ /news_topic.php?id=$1&title=$2 [L]
I want this:
news/title-of-news-article.htm

But every news article is referenced by 'id' which is '$1', i dont want '$1' to show up in the links. And i need spaces rewritten as hypens.

Any help appreciated. Thanks in advanced.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 22-08-2007, 10:53 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,048
Nominated 5 Times in 3 Posts
Nominated TOTW/F/M Award(s): 1
louie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enough
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

unfortunately you need to pass the id as number in the string as you SQL query is based on that and not on the article name.

Spaces and other characteres has to be changed inside the page while creating the a link. Easy done using preg-replace function

PHP Code:
$article_name preg_replace('#[^a-zA-Z0-9]+#','-',$row['article_name']);//replace anything that is NOT a number or letter with - 
Now the rule could be:
Code:
RewriteRule ^article/id([0-9]+)/([^/]*)\.htm$ /news_topic.php?id=$1&title=$2 [L,NC]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 22-08-2007, 11:36 PM
ziycon's Avatar
Wannabe Geek
 
Join Date: Jan 2007
Location: Dublin
Posts: 410
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ziycon will become famous soon enough
Send a message via MSN to ziycon Send a message via Skype™ to ziycon
Default

Code:
RewriteRule ^article/id([0-9]+)/([^/]*)\.htm$ /news_topic.php?id=$1&title=$2 [L,NC]
What output will this give, Got Got it working, just needed to remove the 'id' after 'article/', thanks again for your help.

Last edited by ziycon; 23-08-2007 at 12:51 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 23-08-2007, 08:29 AM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,048
Nominated 5 Times in 3 Posts
Nominated TOTW/F/M Award(s): 1
louie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enough
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

you could also ad the "id" to the href format on your page.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 23-08-2007, 12:34 PM
ziycon's Avatar
Wannabe Geek
 
Join Date: Jan 2007
Location: Dublin
Posts: 410
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ziycon will become famous soon enough
Send a message via MSN to ziycon Send a message via Skype™ to ziycon
Default

I have the link formated like below:

/article-news/1-title-of-news-article.htm

'1' = article id
'title-of-news-article' = article title

Last edited by ziycon; 23-08-2007 at 01:24 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10 (permalink)  
Old 23-08-2007, 01:06 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,048
Nominated 5 Times in 3 Posts
Nominated TOTW/F/M Award(s): 1
louie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enough
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

something doesn't look right but if it's working like that and you are happy with it then leave it the way it is.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
file

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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
Editing a table from a PDF file oliflorence Webmaster Discussion 5 28-05-2007 10:22 PM
Wordpress rewriting htaccess file at random? frankp Coding Help 5 21-04-2007 03:38 PM
PHP Include (Most Recent HTML File)? ButtermilkJack Coding Help 6 29-03-2007 09:19 AM
Wordpress .htaccess file for no-www and mod-rewrite() Cormac Blogs & Blogging 9 20-03-2007 09:31 AM
.pub file bucks General Chat 5 27-01-2007 10:24 PM


Sponsored links

Paid On Results


All times are GMT +1. The time now is 04:24 AM.


Powered by: vBulletin Version 3.7.3, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Hosted in Ireland by Blacknight - Test your ISP |Irish Hosting Directory| Armchair.ie|Logo by Eden Web Design|Avatars by Afterglow |Latest Blog Entries | VPS HostingAd Management by RedTyger

Search Engine Friendly URLs by vBSEO 3.2.0