Welcome Guest, Not a member yet? Register   Sign In
going nuts over a htaccess redirect problem
#1

[eluser]quasiperfect[/eluser]
i'm traing to redirect a url like
Code:
http://localhost/sitemail/site_mail/server/php/site_mail.php?action=value is word of lenght max 9 chars&user_id=value is number of any length&anticash=value is number of any length&anticash=value number of any length
to
Code:
http://localhost/mail_handler/value of action/value of user_id

my htaccess looks like this
Code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond $1 !^(index\.php|js|css|icoane|imagini|sitemail|user_guide|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

any idea on how can i achieve this ?

i can place a htaccess in the folder sitemail/site_mail/server/php/ if necessarily

or i want to redirect any request form the folder sitemail/site_mail/server/php/
to
Code:
http://localhost/mail_handler/value of param1/value of param2/value of param3
#2

[eluser]TheFuzzy0ne[/eluser]
Just out of interest, why do you need to redirect? Why not write the correct URLs to begin with?

For times when you need multiple arguments in no specific order, I wrote an [url="http://ellislab.com/forums/viewthread/106502/"]Alternate URI Syntax library[/url] to help. Would this help you at all?

EDIT: It might be possible to do what you want, but can you guarantee that the arguments in the query string will always be in the same order?
#3

[eluser]quasiperfect[/eluser]
@TheFuzzy0ne because the url is not writen by me but a flash aplication (i can't modifi it in any way) that makes requests to a absolute url
the parameters are added by flash
i'm interested that any request made to the folder http://localhost/sitemail/site_mail/serv...e_mail.php to be redirected to a controller with the values of the first 3 parameters
can be done in any way ?

i tried placing a htaccess in the folder sitemail/site_mail/server/php
Code:
Options +FollowSymLinks
RewriteEngine on
RewriteRule mail_handler/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/$ /sitemail/site_mail/server/php/site_mail.php?$1=$2&$3=$4&$5=$6&$7=$8

but i doesn't work
#4

[eluser]TheFuzzy0ne[/eluser]
In your htaccess you're trying to extract from URI segments, and rewrite to a query string. I thought it was meant to be the other way around?

Or you could just enable query strings.
#5

[eluser]quasiperfect[/eluser]
problem solved
this is a example if anyone has a similar problem

let's say we have the folder /a/b/script.php?param1=value1&param2=value2
u have to place the htaccess file in the folder /a/b/
Code:
RewriteEngine on
RewriteBase /a/b/
RewriteCond %{QUERY_STRING} param1=([^&]*)&param2;=([^&]*)
RewriteRule ^script(.*) /controller/method/%1/%2/? [R,NC]

this will redirect the browser to domain/controller/method/value1/value2

the ? at the end of RewriteRule ^script(.*) /controller/method/%1/%2/? removes any other elements from the original url


hope it helps somebody
#6

[eluser]TheFuzzy0ne[/eluser]
Well done. Thanks for sharing. Smile

Sorry I couldn't be of any more help.




Theme © iAndrew 2016 - Forum software by © MyBB