Go Back  HTML Forums - Free Webmaster Forums and Help Forums > SERVER ADMINISTRATION > Linux Administration
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 10-06-2008, 09:01 PM
  #1
Paul
Super Deity (Level 18)
 
Paul's Avatar
 
Join Date: Mar 2001
Location: 127.0.0.1
Posts: 4,035
iTrader: (0)
Paul has a spectacular aura aboutPaul has a spectacular aura about
Mod Rewrite Question

Hello,

I am having a hard time with a rewrite rule. I would like to make it so that mysite.com/category_name.html rewrites to fetch_templates.php?cat_name=category_name

Is something like this possible? The following doesn't seem to be working properly:

Code:
RewriteRule (.*).html fetch_templates.php?cat_name=$1
__________________

Pawel Kowalski
Albuquerque Web Design

templatesXchange.com - Free Web Templates - Native American Jewelry
Paul is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-07-2008, 02:58 AM
  #2
¥åßßå
Blonde Bimbo
 
¥åßßå's Avatar
 
Join Date: Jul 2004
Posts: 2,415
iTrader: (0)
¥åßßå is a name known to all¥åßßå is a name known to all¥åßßå is a name known to all¥åßßå is a name known to all¥åßßå is a name known to all¥åßßå is a name known to all
You must have some other conflict because this works for me on it's own in .htaccess

Code:
RewriteEngine On
RewriteRule (.*).html fetch_templates.php?cat_name=$1
¥
__________________
I may have opened the door, but you entered of your own free will

¥åßßå is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-07-2008, 09:02 AM
  #3
Paul
Super Deity (Level 18)
 
Paul's Avatar
 
Join Date: Mar 2001
Location: 127.0.0.1
Posts: 4,035
iTrader: (0)
Paul has a spectacular aura aboutPaul has a spectacular aura about
Hmm, that's what I was using. I was seeing some funky behavior. I'm gonna try it again after work and get back.
__________________

Pawel Kowalski
Albuquerque Web Design

templatesXchange.com - Free Web Templates - Native American Jewelry
Paul is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-07-2008, 09:46 AM
  #4
¥åßßå
Blonde Bimbo
 
¥åßßå's Avatar
 
Join Date: Jul 2004
Posts: 2,415
iTrader: (0)
¥åßßå is a name known to all¥åßßå is a name known to all¥åßßå is a name known to all¥åßßå is a name known to all¥åßßå is a name known to all¥åßßå is a name known to all
One possibility is that you have lines after that in htaccess in which case add [QSA,L] after the rule ( Query String Attach, Last )

Code:
RewriteRule (.*).html fetch_templates.php?cat_name=$1 [QSA,L]
¥
__________________
I may have opened the door, but you entered of your own free will

¥åßßå is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-07-2008, 09:49 AM
  #5
Paul
Super Deity (Level 18)
 
Paul's Avatar
 
Join Date: Mar 2001
Location: 127.0.0.1
Posts: 4,035
iTrader: (0)
Paul has a spectacular aura aboutPaul has a spectacular aura about
I did have additional rules after it so that was probably it. Thanks, I'll give this a try and see if it works.
__________________

Pawel Kowalski
Albuquerque Web Design

templatesXchange.com - Free Web Templates - Native American Jewelry
Paul is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-08-2008, 08:48 PM
  #6
Paul
Super Deity (Level 18)
 
Paul's Avatar
 
Join Date: Mar 2001
Location: 127.0.0.1
Posts: 4,035
iTrader: (0)
Paul has a spectacular aura aboutPaul has a spectacular aura about
Seems to work perfectly, thanks (sorry I cant give you any more rep right now).
__________________

Pawel Kowalski
Albuquerque Web Design

templatesXchange.com - Free Web Templates - Native American Jewelry
Paul is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-08-2008, 09:57 PM
  #7
Paul
Super Deity (Level 18)
 
Paul's Avatar
 
Join Date: Mar 2001
Location: 127.0.0.1
Posts: 4,035
iTrader: (0)
Paul has a spectacular aura aboutPaul has a spectacular aura about
Actually there is one thing that is annoying me, it's not a big deal but if it can be fixed that would be great.

This rewrite rule works fine if I do:

xhtml-css-templates.html

The problem is it also works fine if I put something else after .html, such as:

xhtml-css-templates.html23213123124

Is there anyway so that the latter will not work?
__________________

Pawel Kowalski
Albuquerque Web Design

templatesXchange.com - Free Web Templates - Native American Jewelry
Paul is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-09-2008, 01:48 AM
  #8
¥åßßå
Blonde Bimbo
 
¥åßßå's Avatar
 
Join Date: Jul 2004
Posts: 2,415
iTrader: (0)
¥åßßå is a name known to all¥åßßå is a name known to all¥åßßå is a name known to all¥åßßå is a name known to all¥åßßå is a name known to all¥åßßå is a name known to all
This should work

Code:
RewriteRule (.*).html$ fetch_templates.php?cat_name=$1 [QSA,L]
¥
__________________
I may have opened the door, but you entered of your own free will

¥åßßå is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-09-2008, 01:27 PM
  #9
Paul
Super Deity (Level 18)
 
Paul's Avatar
 
Join Date: Mar 2001
Location: 127.0.0.1
Posts: 4,035
iTrader: (0)
Paul has a spectacular aura aboutPaul has a spectacular aura about
That seems to do the trick but now I'm running in to another issue (sorry to keep bugging). Here is my htaccess file:

Code:
RewriteEngine on
RewriteRule p/(.*)/(.*) fetch_templates.php?cat_name=$1&page_num=$2
RewriteRule p/(.*)/(.*)/ fetch_templates.php?cat_name=$1&page_num=$2
RewriteRule templates/(.*).html$ display_template.php?id=$1
RewriteRule (.*).html$ fetch_templates.php?cat_name=$1 [QSA,L]
So anytime someone puts in mysite.com/templates/25.html it should call display_template.php?id=25. However, it actually calls fetch_templates.php?cat_name=25. Is there a way to get around this? I noticed if I change RewriteRule templates/(.*).html$ display_template.php?id=$1 to RewriteRule templates/(.*).htm$ display_template.php?id=$1 it works fine.
__________________

Pawel Kowalski
Albuquerque Web Design

templatesXchange.com - Free Web Templates - Native American Jewelry
Paul is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-09-2008, 03:08 PM
  #10
¥åßßå
Blonde Bimbo
 
¥åßßå's Avatar
 
Join Date: Jul 2004
Posts: 2,415
iTrader: (0)
¥åßßå is a name known to all¥åßßå is a name known to all¥åßßå is a name known to all¥åßßå is a name known to all¥åßßå is a name known to all¥åßßå is a name known to all
I'm guessing it's because it matches the last and 2nd last rule, you need to tell it to stop on first match

Code:
RewriteEngine on
RewriteRule p/(.*)/(.*) fetch_templates.php?cat_name=$1&page_num=$2 [QSA,L]
RewriteRule p/(.*)/(.*)/ fetch_templates.php?cat_name=$1&page_num=$2 [QSA,L]
RewriteRule templates/(.*).html$ display_template.php?id=$1 [QSA,L]
RewriteRule (.*).html$ fetch_templates.php?cat_name=$1 [QSA,L]
¥

Comments on this post
seovb agrees: thanks
__________________
I may have opened the door, but you entered of your own free will

¥åßßå is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-31-2008, 07:10 PM
  #11
seovb
Battler (Level 3)
 
Join Date: Aug 2008
Posts: 22
iTrader: (0)
seovb is an unknown quantity at this point
Thanks, these helped me finally figure some rules out on my site thats been redirecting things all crazy
seovb is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart



 
 


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



 
  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
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 02:19 AM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.