Forum Moderators: phranque

Message Too Old, No Replies

rewrite Folders and Files both

         

Anyango

4:02 pm on Jul 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey Bros

i have always been able to successfully rewrite urls for files and for directories but seperately, never been able to do the both at same time.

leme explain

www.domain.com/index.php?id=10

rewritting it is simple

www.domain.com/directory1/

rewritting this is simple again

but
rewritting both of them in the same .htaccess, how to do that

www.domain.com/directory1/index.php?id=10
www.domain.com/index.php?id=10

i am not a newbie, but am unable to get them to work together.

Any Assistance?

Thank you

Kami

ChadSEO

7:53 pm on Jul 25, 2005 (gmt 0)

10+ Year Member



I'm a little confused as to what is the URL that you have currently, and what are you wanting it to be?

Anyango

8:01 pm on Jul 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hmm leme explain

i have an index.php file in public_html folder.

that takes parameter like this

index.php?page=blahblah

now if someone types in

mydomain.com/test-page.html

i get index.php?page=test-page.html

exactly as what i want

but if someone types in

mydomain.com/directory1/test-page.html

to handle this i have no htaccess code, i want this request to be sent to my index.php like this

mydomain.com/index.php?directory=directory1&page=test-page.html

Thanks

ChadSEO

9:36 pm on Jul 25, 2005 (gmt 0)

10+ Year Member



Assuming you are looking to go just 1 directory deep, and this is in an .htaccess file, you'd be looking for something like this:

RewriteRule ^([^/]+)/(.*\.html)$ /index.php?directory=$1&page=$2 [L]

Depending on how the previous rule was setup up, this may have to go before it. (If it's different, then the order doesn't matter.)

Anyango

7:18 am on Jul 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Alot Bro!

Much Appreciated

it helped really.

Thanks again

Kami