Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

function rewrite WordPress

i have pages using the template page "mytemplate".
this pages are an url like that :
.../slug/1
.../slug/2
("slug" is the slug of the page of course)
etc...
i would a rewrite rules only for this pages.

the rewrite rules :

if the url of the page is .../slug/1 the url become .../slug/magasin

if the url of the page is .../slug/2 the url become .../slug/présentation

if the url of the page is .../slug/3 the url become .../slug/contact



after :
if the url of the page is .../slug/4 the url become .../slug/member1
if the url of the page is .../slug/5 the url become .../slug/member2
if the url of the page is .../slug/6 the url become .../slug/member3
if the url of the page is .../slug/7 the url become .../slug/member4
etc...

Answers (2)

2011-07-27

Jerson Baguio answers:

try to rewrite that with htaccess



Options +FollowSymLinks
RewriteEngine on

RewriteRule ^(.*)/slug/1 /slug/magasin
RewriteRule ^(.*)/slug/2 /slug/présentation

#continue with the rewrites of your other urls


jevusi comments:

i need a function in function.php please


jevusi comments:

and "slug" is an example ;-)

the url can be foo/1 or peter/1 or car/1 or anything else

2011-07-27

Clifford P answers:

You want example.com/cars/1 to redirect to example.com/cars/toyota - and example.com/foo/1 redirect to example.com/foo/bar.
I'm not quite understanding your exact need. It sounds like you want 2 links for each page - are you trying to just have a URL shortener effect?


You could try the functionality of some of these plugins and then leave the right one(s) installed or request a functions.php item to be written that does exactly what you want:
http://wordpress.org/extend/plugins/redirect/ - redirect using custom field
http://wordpress.org/extend/plugins/quick-pagepost-redirect-plugin/ - checkbox per post/page, setting the destination and the redirect type (perm, temp)
http://dardna.com/wp-htaccess-control - rewriting and htaccess editing from WP Admin (change "Author" in URL if you want too)
http://www.deanlee.cn/wordpress/permalinks-migration-plugin/ - if you're just wanting to change your old permalink structure to a new one (probably doesn't apply to your question in specific, but maybe you had another need)

If this helped, great. If I'm way off, please provide more details.
Thanks.
-Cliff


jevusi comments:

i use the tag <!--nextpage-->

so i have this urls :
............/slug-of-the-page/1
............/slug-of-the-page/2
............/slug-of-the-page/3

i want rewrite this urls

............/slug-of-the-page/1 become ............/slug-of-the-page/magasin
............/slug-of-the-page/2 become ............/slug-of-the-page/presentation
............/slug-of-the-page/3 become ............/slug-of-the-page/contact

and

............/slug-of-the-page/4 become ............/slug-of-the-page/member1
............/slug-of-the-page/5 become ............/slug-of-the-page/member2
............/slug-of-the-page/6 become ............/slug-of-the-page/member3
and so
............/slug-of-the-page/60 become ............/slug-of-the-page/member57

is it clear ?


Clifford P comments:

I think I understand. You're saying that you are creating the effect of childpages without actually creating additional WordPress "pages".
If you used child pages, it would be straight-forward, because you could determine your own slug for the child page.
But, since you want to break up a single page into the effect of child pages, you want the url to look pretty (as if it were a child page with its own slug).

Did I get something wrong?
Is there a reason you don't want to create child pages?

P.S. It sounds like you might want to use custom post types.
Assign the category "cars" and post slug "toyota" - have your own "cars" RSS and all that.


jevusi comments:

yes cliff that's it.
so i need a function to rewrite this urls.
is it difficult ?


Clifford P comments:

Is there a reason why you are not using child pages?
Or, better yet, use custom post types and write "posts", not "pages" (I've heard many pages can slow down your site, but not many posts.)


jevusi comments:

Sorry i need a solution with a page... Have you a solution ?


Clifford P comments:

I am unable to provide such a solution at this time. Hopefully my efforts to clarify your request will help someone else. And, if no solution, you at least have an alternative setup. Best regards, Cliff.