views:

96

answers:

5

Hello I want to have some redirection made by .htaccess file: Some examples

mysite.com/accepted -> mysite.com/index.php?type=accepted
mysite.com/waiting -> mysite.com/index.php?type=waiting
mysite.com/cancelled -> mysite.com/index.php?type=cancelled

&

mysite.com/edit/2 - > mysite.com/admin.php?edit=2

ETC. for all numbers possible

mysite.com/login -> mysite.com/admin.php?action=login
mysite.com/register -> mysite.com/admin.php?action=register
mysite.com/lostpassword - > mysite.com/admin.php?action=lostpassword 
mysite.com/add - > mysite.com/add.php

Apprectiate your help ;)

@edit: It should be done that way but with masking urls.

A: 

If you want to get into the topic yourself, www.modrewrite.com hosts a number of great mod_rewrite resources with lots of examples.

Pekka
+1  A: 

Which way around is the redirect? It would be common to see redirects from your given right-hand-sides to the left-hand-sides, but not the other way around.

EDIT I see you've fixed that, so my supposition was correct:

i.e. you'd normally see:

RewriteRule ^edit/([0-9]+)$ /admin.php?edit=$1 [L]

etc, to map the nice friendly RESTful style URL into the internal URL.

Alnitak
A: 

If I understand your edit correctly you want this

<?php
header('Location: http://mysite.com/'.$_GET['type']);
?>
mattanja
A: 

Maybe something like the following?

RewriteRule ^www.domain.com/([^/]+)/([^/]+)/([^/]+)/([^/]+) /index.php?$1=$2&$3=$4 [NC]

do note that you will have to parse the URL (REQUEST_URI) instead of accessing $_GET

Jeremiah Stover
A: 

Since there is no structural pattern in your URLs that can be used to map the URLs to the destinations, you probably will need to use one rule for each group like these:

RewriteRule ^add$ add.php [L]
RewriteRule ^(login|register|lostpassword)$ admin.php?action=$1 [L]
RewriteRule ^edit/(\d+)$ admin.php?edit=$1 [L]
RewriteRule ^(accept|waiting|canceled)$ index.php?type=$1 [L]
Gumbo