Forum Moderators: phranque

Message Too Old, No Replies

[apache/modrewrite] redirect subdomain and paths

I tried and searched a lot but found nothing

         

Ruben

8:19 pm on Mar 15, 2006 (gmt 0)

10+ Year Member



For a site I need the following rewrite rule:

For example:

subdomain.domain.com/dir1/file1.html

needs to be rewriten to:

domain.com/index.php?sub=subdomain&dir=dir1&file=file1

Someone has suggestions for this?

jdMorgan

1:15 am on Mar 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can start with the code in this thread [webmasterworld.com], and work from there.

For more information, please see our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

Ruben

8:46 am on Mar 16, 2006 (gmt 0)

10+ Year Member



The subdomain stuff is already working.. but in combination with the dir and file it isn't working anymore.

I have for the file and dir stuff something like:

RewriteEngine on
RewriteRule ^(.*)\.html $1\.php
RewriteRule ^([^/]*)/([^/]*)$ /index.php?categorie=$1 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?categorie=$1&param1=$2 [L]

This gives some strange behavior.

jdMorgan

4:49 pm on Mar 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We can't see your access or error logs, so please describe the "strange behaviour."

What URL do you request, how is it rewritten, and how does this differ from your expectations?

Jim

Ruben

6:33 pm on Mar 17, 2006 (gmt 0)

10+ Year Member



Well it seems very difficault to do a good subdomain and path redirect.. i maybe have another question.

I now want to do it as follows:

RewriteRule ^(.*)$ index.php?path=$1

<?
$path = $_GET['path'];
$path_parts = explode("/", $path);
$reversed_path_parts = array_reverse($path_parts);
$file = $reversed_path_parts[0];
$last_dir = $reversed_path_parts[1];
?>

But for some reason the RewriteRule doesn't work..