www.webdeveloper.com
Results 1 to 2 of 2

Thread: .htaccess mod_rewrite URL making relative directories break

  1. #1
    Join Date
    Oct 2008
    Location
    Melbourne, Australia
    Posts
    34

    .htaccess mod_rewrite URL making relative directories break

    Okay so I'm rewriting a URL domain.com/id/text to domain.com/page.php?id=id using mod_rewrite / htaccess

    Code:
        Options +FollowSymlinks
        RewriteEngine on
        RewriteCond %{http_host} ^webresauce.com [nc]
        RewriteRule ^(.*)$ http://www.webresauce.com/$1 [r=301,nc]
        
        # Rewite URL Starts here
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^([^/]+)/([^/]+)/?$ read-post.php?id=$1&n=$2 [QSA,L]
    It does what it's supposed to except the images and links all think they're in the folder domain.com/id/ - they obviously aren't. I want to avoid using a full URL for the images etc so I don't need to change my developing URLs and Live URLs among other things.

    Is there anyway using htaccess I can make it so it gets the files from the base directory not the non-existant one.

    This:
    http://www.webresauce.com/5712/gfhhdfg

    Should look like this:
    http://www.webresauce.com/read-post.php?id=5712

    Any help would be much appreciated

  2. #2
    Join Date
    Nov 2009
    Location
    Tacoma, WA
    Posts
    22
    I have been having the exact same issue and can't find the solution anywhere X__X

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles