The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Redirect problem

Discussion in 'General Discussion' started by modrewrite, Nov 26, 2009.

  1. modrewrite

    modrewrite Registered

    Joined:
    Nov 26, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Hello, I have a problem with .htaccess and I know it's likely to be apache or server related, but I think it also might be related to how subdomains are handled by cPanel.

    I have a subdomain with lots of directories inside. The subdomain was set thru cPanel.
    Example:
    http://one.domain.com/dir1/dir2/dir3/
    http://one.domain.com/something1/
    http://one.domain.com/something2/

    I want this to be rewritten to
    http://one.domain.com/show.php?w=dir1/dir2/dir3/
    http://one.domain.com/show.php?w=something1/
    http://one.domain.com/show.php?w=something1/subdir1/
    yet not shown in the address bar.

    I have created this .htaccess file:

    Code:
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{HTTP_HOST} ^one.domain.com$ [NC]
    RewriteRule ^(.*)$ /show.php?w=$1 [L]


    However, there is a problem when the URLs don't end with a slash, like this:
    http://one.domain.com/dir1

    http://one.domain.com/dir1/ displays in the address bar correctly, however
    http://one.domain.com/dir1 does redirect properly, but displays as http://one.domain.com/dir1/?w=dir1 in the address bar. Which is weird.

    This happens with any level of subdirectories, i.e.
    http://one.domain.com/dir1/dir2/dir3
    becomes
    http://one.domain.com/dir1/dir2/dir3/?w=dir1/dir2/dir3

    I have noticed that this only happens when the URL is handling real directories.
    Let's say dir1 exists. http://one.domain.com/dir1 displays http://one.domain.com/dir1/?w=dir1
    but if dir2 doesn't exist, http://one.domain.com/dir2 remains unchanged in the address bar.

    My subdomain is also accessible as a subdirectory of the main domain: http://domain.com/one/
    Could there be the problem? Also in cPanel redirect section I see this:
    one.domain.com / /show.php?w= temporary


    I searched high and low but haven't found a way to fix that.
    Hope somebody could help. Thanks!
     
Loading...

Share This Page