homepage Welcome to WebmasterWorld Guest from 23.22.173.58
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
htaccess rewrite - applied to final directory name of URL
el_roboto

5+ Year Member



 
Msg#: 3460637 posted 7:12 pm on Sep 25, 2007 (gmt 0)

I haven't done much with htaccess for a few months, I'm hoping to achieve the goals below, I know number 1 is possible as I have applied it previously, but how about number 2? I'm off do a refresh on htaccess anyway but any suggestions on the second goal would be appreciated, even links!

1) unless a file type is specified, add a trailing backslash to URL
ie: from www.this.com/hello/webmaster/control_panel
to www.this.com/hello/webmaster/control_panel/

2) rewrite URL based on the final directory of the specified URL
ie: from www.this.com/hello/webmaster/control_panel/
to www.this.com/index.php?id=control_panel
OR from www.this.com/something/fruit/green/apples/
to www.this.com/index.php?id=apples
This rule needs to assess what is between the final two forward slashes

 

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3460637 posted 11:29 pm on Sep 25, 2007 (gmt 0)

1) Add trailing slash if no filetype.

We covered that many times here. Did you try a search?

2) rewrite URL based on the final directory of the specified URL

Sounds like a fairly simple regular-expressions and back-reference problem then. A pattern such as
^([^/]+/)*([^/]+)/$
with a back-reference to $2 should solve that relatively efficiently...

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

el_roboto

5+ Year Member



 
Msg#: 3460637 posted 9:27 am on Oct 5, 2007 (gmt 0)

thanks jim got it

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved