Welcome to WebmasterWorld Guest from 54.211.180.70

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

htaccess rewrite - applied to final directory name of URL

     
7:12 pm on Sep 25, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 14, 2007
posts:92
votes: 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

11:29 pm on Sept 25, 2007 (gmt 0)

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 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

9:27 am on Oct 5, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 14, 2007
posts:92
votes: 0


thanks jim got it
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members