PDA

View Full Version : htaccess redirect and '?'


SKEMONE
10-15-2003, 11:09 AM
hi everybody,

this question might be to indept but I'll try anyways...

I managed to send a variabel from the address bar in your browser to a flashmovie placed inside a .html file.

What I want to do now is to use a RewriteRule in my .htaccess file placed in the root of my site.

This is what I have:

# Rewrite directories
# Global

RewriteEngine on
RewriteBase /

# Rewrite rules, Sorted by client
#test
RewriteRule test index.html?test

this means that if you request www.mydomain.com/test the browser would be redirected to www.mydomain.com/index.html?test

but... the browser gets redirected to www.mydomain.com/index.html not taking the part from the '?'to the end... I think it has something to do with the fact that the '?' is probably a syntax symbol.

Does anyone know a way to work around this???

tnx in advance

Skem

freddycodes
10-15-2003, 09:52 PM
Will you only have set variables such as test and other one word values, or did you want to say pass whatever happens to be after the mydomain.com/whateverblahblah

to index.html?

SKEMONE
10-16-2003, 05:37 AM
huh? I don't think I understand what you're saying... :confused:

What I want if a user requests 'www.mydomain.com/test' I want the user to be redirected to 'www.mydomain.com/index.html?test'.

in other words if a user types in the adress bar of his browser: 'www.mydomain.com/test' and presses enter... 'www.mydomain.com/index.html?test' will appear in his adress bar and be directed to that page (including passing through the word 'test' to the page índex.html')

hope this is clearer

greets skem

freddycodes
10-16-2003, 12:25 PM
No what you are saying makes perfect sense. Maybe I am not asking my question clearly.


index.html?test means nothing. test is now a query string variable name with no value. Will there be other variable names being passed to index.html like say

http://www.domain.com/foo points to http://www.domain.com/index.html?foo

It matters when making the regex pattern for matching in the rewrite rules.


By catching every request in that manner and forwarding to index.html, you realize it will mean every time anyone goes to any page on your site they will be redirected to index.html. Are there special rules to implemenetd like if theuser types in

http://www.domain.com/aboutus.html

Will it actually go to aboutus.html or will it redirect to

http://www.domain.com/index.html?aboutus.html


You see what I am saying. Could you clarify on a few of these points.


There has to be some exclusions or every request will cause an infinte loop. Or is it always to just redirect when using the word test.


Anyways for just the word test it should look like.


RewriteEngine on
RewriteBase /

# Rewrite rules, Sorted by client
#test
RewriteRule test$ /index.html?test [R]

SKEMONE
10-17-2003, 05:50 AM
ok, now I think I got it... What I'm doing is indeed just sending a substring but this strig is used (using the document.write()) to place a swf in a html page with a variabel


example: if you request index.html?company_profile the html page will send it through to this... main.swf?beginSWF=company_profile... I've got this all working.

so if the user requests /test it will have to be redirected (using .htaccess) to /index.html?test which will request main.swf?beginSWF=test

I'll try the method you described

tnx SKEM

SKEMONE
10-17-2003, 05:54 AM
BINGO BANGO!!!:D

it works great... tnx alot!

SKEM-one