homepage Welcome to WebmasterWorld Guest from 54.204.249.184
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

    
Mod Rewrite Rules for custom URL structure
Spinmeister




msg:4451281
 1:15 pm on May 9, 2012 (gmt 0)

I have a wordpress site and would like to setup custom URLs. Normally, I can use the wordpress permalinks settings to take a URL like:

http://example.com/p=14

to

http://example.com/category/post-name

But what I want is:

http://example.com/category-post-name.html

Or, even better,

http://example.com/keyword-category-post-name.html

To be clear, "keyword" would always be the same for every URL. It's not a variable.

Getting the .html to show up is no problem, the parts I'm having a problem with are getting the keyword to be inserted in all the URLs just before the category name, and to remove the / that normally would be between the category and post / page name.

 

lucy24




msg:4451552
 10:40 pm on May 9, 2012 (gmt 0)

For starters: WordPress is tricky (some people may use a stronger word) because it probably comes with its own htaccess. So you have to be very careful to ensure that your own additions don't conflict with what is already there.

How do you get from the single item "p=14" to the two items "category" (or "keyword-category") and "post-name"? Once you've figured this out, the choice between / and - is simply punctuation. In fact it's a good idea to make the change, if /category/ isn't really a directory (real or fake doesn't matter).

Someone else is going to read you the riot act about appending ".html" when it isn't already there from natural causes ;)

incrediBILL




msg:4451757
 11:18 am on May 10, 2012 (gmt 0)


But what I want is:

http://example.com/category-post-name.html


No. You don't.

People remove .html from their sites, not add it.

I made two sites extensionless just this week.

No extensions whatsoever should be exposed if possible.

The real upside to going extensionless is you can change the technology under the site at any time because it doesn't matter if it's .html, .php, .asp, .pl, .jsp or whatever and there is certainly no need to tell hackers so they have an easy clue how to start attacking.

Maybe Tim Berners-Lee's article at the W3C will convince you.
He's just the guy that invented the web, but what does he know?
[w3.org...] <-no file extension at w3c, shock!

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