Results 1 to 2 of 2

Thread: .htaccess domain-level mod_rewrite appends change in visible URL

  1. #1
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default .htaccess domain-level mod_rewrite appends change in visible URL

    I switched to a host for several of my domains that requires a "main" domain.
    I don't have access to anything in the server configuration that lets me change that.

    What I want is to host multiple sites, and have none of them located in the root folder.

    In other words, I want the root folder to contain (in addition to several configuration files) /mydomain1.com/, /mydomain2.com/, etc.

    This works fine except for that main domain that is supposed to be located in the root.

    In order to work around this, I'm using mod_rewrite via .htaccess.

    Here's my .htaccess file:
    Code:
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ci-pro.com
    RewriteCond %{REQUEST_URI} !^/ci-pro.com
    RewriteRule ^(.*)$ ci-pro.com%{REQUEST_URI}
    Here's the site:
    http://ci-pro.com


    Everything works well, except for one thing: the extra "ci-pro.com/" is appended to the URL when I visit a link. Load the page then click one of the links in the header-- it doubles the domain name (one for the domain, another for the subdirectory).

    This is really annoying and I can't find any way around it or any information about this. I thought that mod_rewrite was supposed to be completely silent...
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    An update and partial solution:

    I missed that my links had no trailing slashes:
    /mydir
    instead of:
    /mydir/

    By adding the slashes, it made everything work.

    In other words, the trailing slash is required by the server and the rewrite is converted to a redirect if it has no trailing slash (and it's a directory, not a file).

    This doesn't exactly solve the original problem, but by adding a trailing slash to every link on my site now the error no longer appears. It's at least a solid temporary solution.


    Now I wonder if there's any way to disable this requirement for a trailing slash...
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •