PDA

View Full Version : mod_rewrite double redirect question


eemerge
01-17-2007, 03:31 AM
Hello.

Maybe someone could help me with a mod_rewrite/.htaccess problem

The setup is like this:

I already have a .htaccess in the main domain (domain.com) , that redirects user subdomains ( user.domain.com) to /users/user. (thanks goes to schleppel, a member of this here forum :) ).

Now the problem is: i have installed lifetype blog in www.domain.com/lifetype/. What im trying to do is: when a user enters myname.domain.com in the browser, it should be redirected to his lifetype blog. (http://www.domain.com/lifetype/index.php?blogId=2)

But i still need to go through that initial path :

user.domain.com ---> redirect to users/user ---> user.domain.com/index.php?blogId=1 (this is how the link in the browser should look when user accesses his blog; this link is something like: www.domain.com/lifetype/index.php?blogId=1 , just i want it to be in the user.domain.com format).

What i did , is put a .htaccess in users/user ..which does some part of the job. It redirects me to the user's blog, but the paths in the html files are all screwed and im not getting any layout/css/images. For example, an image has the SRC = user.domain.com/image.gif and i guess it should be like user.domain.com/images/image.gif.

Also another thing is, lifetype (for those who have 'played' with this blog software) is setup for using subdomains , so this could be another problem but im not sure of it , because the initial user.domain.com redirects first to users/user then lifetype gets the user.domain.com and does its stuff too , to show the blog for that user.

I think i havent made myself very clear, but i hope its pretty understandable.

I guess the problem would be : how to redirect so that the html pages get the correct path to use with images.

I will post here the 2 .htaccess

1. users/user HTACCESS
RewriteEngine ON
RewriteRule ^(.*)$ %1/lifetype/ [L]

2. lifetype`s own .htaccess
( the ITALICS are my addition to .htaccess )

#<Files .htaccess>
#deny from all
#</Files>

#<Files config.properties.php>
#deny from all
#</Files>

Options -Indexes
Options +FollowSymLinks

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /

[I]#mystuff
RewriteRule ^/(.*)$ /path/to/htdocs/www.domain.com/lifetype/$1 [L]
#end mystuff

# Permalink to the blog entry (i.e. /1_userfoo/archive/3_title-foo-bar.html)
RewriteRule ^([0-9]+)_[^/]+/archive/([0-9]+)_[^.]+\.html$ index.php?op=ViewArticle&blogId=$1&articleId=$2 [L,NC]

# Monthly archive (i.e. /1_userfoo/archive/200401.html)
RewriteRule ^([0-9]+)_[^/]+/archive/([0-9]{6})\.html$ index.php?blogId=$1&Date=$2 [L,NC]
# -- same as above but with paging included
RewriteRule ^([0-9]+)_[^/]+/archive/([0-9]{6})\.html\.page\.([1-9]+)$ index.php?blogId=$1&Date=$2&page=$3 [L,NC]

# Daily archive (i.e. /1_blogfoo/archive/20040101.html)
RewriteRule ^([0-9]+)_[^/]+/archive/([0-9]{8})\.html$ index.php?blogId=$1&Date=$2 [L,NC]
# -- same as above but with paging included
RewriteRule ^([0-9]+)_[^/]+/archive/([0-9]{8})\.html\.page\.([1-9]+)$ index.php?blogId=$1&Date=$2&page=$3 [L,NC]

# Album (i.e. /88_userfoo/albums/34_title-foo-bar.html)
RewriteRule ^([0-9]+)_[^/]+/albums/([0-9]+)_[^.]+\.html$ index.php?op=ViewAlbum&blogId=$1&albumId=$2 [L,NC]
# -- same as above but with paging included
RewriteRule ^([0-9]+)_[^/]+/albums/([0-9]+)_[^.]+\.html\.page\.([1-9]+)$ index.php?op=ViewAlbum&blogId=$1&albumId=$2&page=$3 [L,NC]

# Albums (i.e. /88_userfoo/albums/)
RewriteRule ^([0-9]+)_[^/]+/albums/$ index.php?op=ViewAlbum&blogId=$1&albumId=0 [L,NC]

# Category view (i.e. /88_userfoo/categories/4_cat-foobar.html)
RewriteRule ^([0-9]+)_[^/]+/categories/([0-9]+)_[^.]+\.html$ index.php?blogId=$1&postCategoryId=$2 [L,NC]
# -- same as above but with paging included
RewriteRule ^([0-9]+)_[^/]+/categories/([0-9]+)_[^.]+\.html\.page\.([1-9]+)$ index.php?blogId=$1&postCategoryId=$2&page=$3 [L,NC]

# Category-Feeds (i.e. /3_userfoo/feeds/categories/2_category/atom)
RewriteRule ^([0-9]+)_[^/]+/feeds/categories/([0-9]+)_[^.]+/(.*)$ rss.php?blogId=$1&categoryId=$2&profile=$3 [L,NC]

# Feeds (i.e. /3_userfoo/feeds/atom)
RewriteRule ^([0-9]+)_[^/]+/feeds/(.*)$ rss.php?blogId=$1&profile=$2 [L,NC]

# Trackbacks (i.e. /3_userfoo/trackbacks/34_title-foo-bar.html)
RewriteRule ^([0-9]+)_[^/]+/trackbacks/([0-9]+)_[^.]+\.html$ index.php?op=Trackbacks&blogId=$1&articleId=$2 [L,NC]

# Comment form (i.e. /88_userfoo/comment/34_title-foo-bar.html)
RewriteRule ^([0-9]+)_[^/]+/comment/([0-9]+)_[^.]+\.html$ index.php?op=Comment&blogId=$1&articleId=$2 [L,NC]

# Resources (i.e. /88_userfoo/resources/this-is-a-resource-name.pdf.html)
RewriteRule ^([0-9]+)_[^/]+/resources/([^.]+)\.([^.]+)\.html$ index.php?op=ViewResource&blogId=$1&resource=$2.$3 [L,NC]

# Download a resource (i.e. /88_userfoo/get/this-is-a-resource-name.pdf)
RewriteRule ^([0-9]+)_[^/]+/get/(.+)$ resserver.php?blogId=$1&resource=$2 [L,NC]

# A non-default blog (i.e. /88_userfoo)
RewriteRule ^([0-9]+)(_[^/]+)?$ index.php?blogId=$1 [L,NC]
# -- same as above but with paging included
RewriteRule ^([0-9]+)(_[^/]+)\.page\.([1-9]+)$ index.php?blogId=$1&page=$3 [L,NC]

# Static Pages (i.e /3_userfoo/demosites)
RewriteRule ^([0-9]+)_[^/]+/(.+)$ index.php?op=Template&blogId=$1&show=$2 [NC]

</IfModule>



<Files post>
ForceType application/x-httpd-php
</Files>

<Files archives>
ForceType application/x-httpd-php
</Files>

<Files static>
ForceType application/x-httpd-php
</Files>

<Files rss>
ForceType application/x-httpd-php
</Files>

<Files category>
ForceType application/x-httpd-php
</Files>

<Files trackbacks>
ForceType application/x-httpd-php
</Files>

<Files comment>
ForceType application/x-httpd-php
</Files>

<Files resource>
ForceType application/x-httpd-php
</Files>

<Files get>
ForceType application/x-httpd-php
</Files>

<Files album>
ForceType application/x-httpd-php
</Files>

<Files blog>
ForceType application/x-httpd-php
</Files>

<Files user>
ForceType application/x-httpd-php
</Files>

<Files page>
ForceType application/x-httpd-php
</Files>

ErrorDocument 401 /error.php
ErrorDocument 403 /error.php
ErrorDocument 404 /error.php


Thanks a lot in advance to anyone who could help .