Forum Moderators: phranque

Message Too Old, No Replies

RewriteRules - Have I got it right

         

superjacent

6:34 am on May 13, 2008 (gmt 0)

10+ Year Member



I'm about to move my personal blogging site from a sub-directory back to the root.

Presently, individual url's appear like so:

http://example.net/cms/?q=node/838

and comments to posts appear like so:

http://example.net/cms/?q=node/838#comment-5483

I'm wanting to rewrite the url's so they appear like this:

http://example.net/node/838
or if comments then
http://example.net/node/838#comment-5483

Before I start making changes would appreciate some confirmation or advice re - RewriteRules.

This is the rule I've got in mind

RewriteRule ^cms/\?q=node/([0-9]+.*)$ node/$1 [R=301]

[edited by: encyclo at 9:22 am (utc) on May 13, 2008]
[edit reason] examplified [/edit]

jdMorgan

2:02 pm on May 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your URLs will appear as determined by the links on your pages -- mod_rewrite cannot change that.

Once you have changed the links on all of your pages, you can use mod_rewrite to do two things:
1) Tell the server where to go in the filesystem in order to serve the content for those new URLs.
2) Externally redirect clients (browsers and search engine robots) to the a new URL if they ask for an old one.

See this thread [webmasterworld.com] for more information.

Jim

[edited by: jdMorgan at 2:03 pm (utc) on May 13, 2008]