Forum Moderators: phranque

Message Too Old, No Replies

htaccess help

         

cnilsson

3:04 pm on May 13, 2003 (gmt 0)

10+ Year Member



Hi.
I need to forward url's using htaccess like this:

[domain.com...]
to ->
[domain.com...]

and if possible still show the first url format in the address bar in the browser.

Can this be done, and how?

Thank You.

irock

3:36 pm on May 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



R u suing PHP? If so, try this...

Create a index (NO EXTENSION) file in the (http://domain.com/dir1/) and put these 2 lines in the beginning.
--------------------------------------
$var_array = explode("/",$PATH_INFO);
print $var_array[0];
print "<br>";
print $var_array[1];
--------------------------------------
Entering the URL [domain.com...] will return:
xxxx
yyyy

With this solution, you just have to make sure that 'site' goes first and then follows by 'id' in the URL format. If not, you can mix up your variables.

Next step...
Put this in the .htaccess in the [domain.com...]
---------------------------------------
ForceType application/x-httpd-php
---------------------------------------

This .htaccess forces the server to parse PHP even though thre's no extension for files located under [domain.com...]

At the end, you must insert 'index' between 'http://domain.com/dir1/' and '/xxxx/yyyy/' for this to work.
[domain.com...]

Hope this helps!

jdMorgan

4:18 pm on May 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



cnilsson,

Welcome to WebmasterWorld [webmasterworld.com]!

Something like this added to your .htaccess file, which rewrites
[domain.com...] -> [domain.com...]
should work. (See the reference below, and the links cited in that reference, if you need to modify it)


Options +FollowSymLinks
RewriteEngine on
RewriteRule ^/dir1/([^/])/([^/])/(.*)$ /dir1/$3?site=$1&id=$2 [L]

Ref: Introduction to mod_rewrite [webmasterworld.com]

HTH,
Jim