Combining 2 rewrite rules possible?

Having trouble installing serendipity?
Post Reply
bwakkie
Posts: 2
Joined: Tue Nov 20, 2007 7:07 pm

Combining 2 rewrite rules possible?

Post by bwakkie »

Hi,

I have the following setup:

On my virtual host I did setup the following rewrite rule:

Code: Select all

        # Rewrite <subdomain>.mydomain.com/<path> to mydomain.com/<subdomain>/<path>
        #
        # Skip rewrite if no hostname or if subdomain is www
        RewriteCond %{HTTP_HOST} .
        RewriteCond %{HTTP_HOST} !^www\. [NC]
        # Extract (required) subdomain (%1), and first path element (%3), discard port number if present (%2)
        RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.mydomain\.com(:80)?<>/([^/]*) [NC]
        # Rewrite only when subdomain not equal to first path element (prevents mod_rewrite recursion)
        RewriteCond %1<>%3 !^(.*)<>\1$ [NC]
        # Rewrite to /subdomain/path
        RewriteRule ^(.*) /%1/$1 [L]
..which results that I can access the blog the following way:
http://myblog.mydomain.com/ instead of http://www.mydomain.com/myblog.

This is very convenient for me as I just can create a new folder and I can access it directly as a subdomain.

then the s9y .htaccess should do something with the url but there something goes wrong.

If I take css as example: in the source code of the index.php page that I see the css is requested is the correct url I would expect...

http://myblog.mydomain.com/serendipity.css

... this url is re-written by my own rules first ...

http://mydomain.com/myblog/serendipity.css

...and s9y should translate this on its turn into...

http://mydomain.com/myblog/index.php?ur ... dipity.css

Now my question is what did I not see and you do (hopefully)?

database settings:

Code: Select all

356182;"dbNames";"false";"0"
356183;"serendipityPath";"/var/www/www.mydomain.com/myblog/";"0"
356184;"uploadPath";"uploads/";"0"
356185;"serendipityHTTPPath";"/";"0" /* tried with /myblog/ too*/
356186;"templatePath";"templates/";"0"
356187;"uploadHTTPPath";"uploads/";"0"
356188;"baseURL";"http://myblog.mydomain.com/";"0"
356189;"autodetect_baseURL";"false";"0" /* tried true too*/
356190;"indexFile";"index.php";"0"
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Combining 2 rewrite rules possible?

Post by garvinhicking »

Hi!

Serendipity does not support running on different paths ("/" vs. "blog/"), so you'll always have problems with relative links using your syntax.

Your URL rewriting AFAIK does not reset the $_SERVER['REQUEST_URI'] variable, which is the variable that s9y needs to enable permalink detection.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
bwakkie
Posts: 2
Joined: Tue Nov 20, 2007 7:07 pm

Re: Combining 2 rewrite rules possible?

Post by bwakkie »

garvinhicking wrote:Hi!

Serendipity does not support running on different paths ("/" vs. "blog/"), so you'll always have problems with relative links using your syntax.

Your URL rewriting AFAIK does not reset the $_SERVER['REQUEST_URI'] variable, which is the variable that s9y needs to enable permalink detection.

Regards,
Garvin
Of course this must be possible.... with mod_rewrite you can fool anybody so definitely s9y ;-)

So the problem where apache configuration related. I needed to add

Code: Select all

Options +FollowSymLinks
to the .htaccess file


cheers, soon my very first blog! ;-) (although i am for years professional webmaster i never found the time to investigate in things like this...)
Post Reply