SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    rewrite rule for index.php but not for /www/prettyurl

    Hi,
    The situation I have a front-end site
    in the root (with pretty url like
    /shop /aboutus)
    and a back-end site in /www
    (with pretty url like
    /www/admin/index /www/admin/index/index/id/1 )
    each with a .htaccess.
    htaccess front-end
    PHP Code:
    RewriteEngine On

    # if a directory or a file exists, use it directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond 
    %{REQUEST_FILENAME} !-d

    # otherwise forward it to index.php
    RewriteRule .* index.php
    RewriteRule 
    .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L
    htaccess back-end
    PHP Code:
    SetEnv APPLICATION_ENV development


    RewriteEngine on
    RewriteBase 
    /sharintsito/www/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond 
    %{REQUEST_FILENAME} !-d
    RewriteRule 
    !\.(js|ico|txt|gif|jpg|png|css)$ index.php

    # Security: Don't allow browsing of directories
    Options -Indexes 

    The problem is when I go to for instance
    /www/admin/index
    the first .htaccess intercept the request
    and follow his logic so I'm wondering if there is
    a way to skip it.

    I tried (in the front-end) with
    PHP Code:
    RewriteRule ^(www)($|/) - [L
    but it doesn't work

    can you help me, please ?

  2. #2
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,149
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    I think it's the RewriteBase that did you in. Here's a sampling from the logs that shows how Apache churns things out. (I highlighted what I think are the more important parts.)

    strip per-dir prefix: C:/Apache24/htdocs/www/admin/some/path -> admin/some/path
    applying pattern '\\.(js|ico|txt|gif|jpg|png|css)$' to uri 'admin/some/path'
    RewriteCond: input='C:/Apache24/htdocs/www/admin/some/path' pattern='!-f' => matched
    RewriteCond: input='C:/Apache24/htdocs/www/admin/some/path' pattern='!-d' => matched
    rewrite 'admin/some/path' -> 'index.php'
    add per-dir prefix: index.php -> C:/Apache24/htdocs/www/index.php
    trying to replace prefix C:/Apache24/htdocs/www/ with /sharintsito/www/
    strip matching prefix: C:/Apache24/htdocs/www/index.php -> index.php
    add subst prefix: index.php -> /sharintsito/www/index.php
    internal redirect with /sharintsito/www/index.php [INTERNAL REDIRECT]

    strip per-dir prefix: C:/Apache24/htdocs/sharintsito/www/index.php -> sharintsito/www/index.php
    applying pattern '.*' to uri 'sharintsito/www/index.php'
    RewriteCond: input='C:/Apache24/htdocs/sharintsito/www/index.php' pattern='!-f' => matched
    RewriteCond: input='C:/Apache24/htdocs/sharintsito/www/index.php' pattern='!-d' => matched
    rewrite 'sharintsito/www/index.php' -> 'index.php'
    add per-dir prefix: index.php -> C:/Apache24/htdocs/index.php
    "First make it work. Then make it better."

  3. #3
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Jeff but in the hurry I made a mistake it's
    PHP Code:
    RewriteBase /www
    not
    PHP Code:
    RewriteBase /sharintsito/www

  4. #4
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,149
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Well... I don't know if you'll like this answer better or worse... but when I make that one simple change, then everything works exactly as expected on my local server. Any chance that there's more we haven't seen from your htaccess or from your main config?
    "First make it work. Then make it better."


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •