Dynadot

Htaccess issues, bane of my existance

Spaceship Spaceship
Watch

BillyConnite

<img src="images/smilies/biggrin.gif" border="0" cVIP Member
Impact
109
Hi all,

Need some help here with htaccess, this is a tad complicated:

1) I have a .htaccess file located in the root directory of http://forums.do/ - This htaccess redirects all subdomains to the folder /instance/ (http://forums.do/instance/).

2) This means the virtual root directory of any subdomain is http://forums.do/instance/

3) The above works great. However, accessing http://subdomain.forums.do/instance/ works too... I'm trying to remove that possibility.

4) I have tried using the REQUEST_URI variable to redirect, however when viewing either http://subdomain.forums.do/ or http://subdomain.forums.do/instance/ the REQUEST_URI is the same for both (When you would think accessing through the subdomain's root would NOT produce the '/instance/' in the URI). This leads to an infinite loop. I have tried doing this with the htaccess located at http://forums.do/ AND http://forums.do/instance/

5) PHP can detect the difference just fine, so i currently have any php file located within that folder redirect to the subdomain root.

However i wish to restrict access to the http://subdomain.forums.do/instance/ folder altogether, rather than just the php files located in that folder.

You can see what i mean by visiting http://webmaster.forums.do/test.php and http://webmaster.forums.do/instance/test.php

They both yield the same results, but i want to redirect http://webmaster.forums.do/instance/test.php BACK to http://webmaster.forums.do/test.php

The phpinfo shows the REQUEST_URI as 'test.php' when viewing http://webmaster.forums.do/test.php however viewing http://webmaster.forums.do/instance/test.php shows REQUEST_URI as '/instance/test.php' - This would mean i can use REQUEST_URI within htaccess, however - This is NOT the case with htaccess, both URL's produce the same URI, this is my problem, i cannot rely on REQUEST_URI when trying to redirect traffic from http://subdomain.forums.do/instance/.

I tried to word this as best i could, i hope you can understand what's going on here.

Rhett.
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Hey all,

I edited this post previously as resolved, however it was only a temporary solution with php.

So i'm BUMPING it :P, i have reworded it to be as specific as possible. My htaccess files are below, in case you need some info.

http://forums.do/.htaccess
Code:
Options +FollowSymlinks
RewriteEngine on
ErrorDocument 404 http://forums.do/coming-soon.html
DirectoryIndex index.php index.html



RewriteRule ^index.html index.php [NC]
RewriteRule ^register.html register.php [NC]
RewriteRule ^success.html success.php [NC]
RewriteRule ^activate.html activate.php [NC]
RewriteRule ^tos.html tos.php [NC]
RewriteRule ^random.html random.php [NC]




RewriteCond %{HTTP_HOST} ^search.forums.do [NC]
RewriteRule ^(.*)$ /search/$1 [L,NC]

RewriteCond %{HTTP_HOST} ^deusex3.forums.do [NC]
RewriteRule ^(.*)$ http://deusex3forums.com/$1 [L,NC]

RewriteCond %{HTTP_HOST} ^portal2.forums.do [NC]
RewriteRule ^(.*)$ http://portal2forums.net/$1 [L,NC]

RewriteCond %{HTTP_HOST} ^fable3.forums.do [NC]
RewriteRule ^(.*)$ http://fable3forums.net/$1 [L,NC]

RewriteCond %{HTTP_HOST} ^battlefieldplay4free.forums.do [NC]
RewriteRule ^(.*)$ http://battlefieldplay4freeforums.com/$1 [L,NC]

RewriteCond %{HTTP_HOST} ^falloutonline.forums.do [NC]
RewriteRule ^(.*)$ http://falloutonlineforums.com/$1 [L,NC]

RewriteCond %{HTTP_HOST} ^bioshockinfinite.forums.do [NC]
RewriteRule ^(.*)$ http://bioshockinfiniteforums.com/$1 [L,NC]




RewriteCond %{HTTP_HOST} ^forum.forums.do [NC,OR]
RewriteCond %{HTTP_HOST} ^forums.forums.do [NC]
RewriteRule ^(.*)$ http://forums.do/forums/$1 [L,NC]

RewriteCond %{HTTP_HOST} ^forum.forums.cx [NC,OR]
RewriteCond %{HTTP_HOST} ^forums.forums.cx [NC]
RewriteRule ^(.*)$ http://forums.do/forums/$1 [L,NC]

RewriteCond %{HTTP_HOST} ([^\.]+).forums.do [NC]
RewriteCond %{HTTP_HOST} !^forums.do$ [NC]
RewriteCond %{HTTP_HOST} !^www.forums.do$ [NC]
RewriteCond %{HTTP_HOST} !^forum.forums.do$ [NC]
RewriteCond %{HTTP_HOST} !^forums.forums.do$ [NC]
RewriteCond %{REQUEST_URI} !^/instance/ [NC]
RewriteRule ^(.*)$ /instance/$1 [L,NC]

#RewriteCond %{REQUEST_URI} ^/instance/test.php$ [NC]
#RewriteRule ^(.*)$ http://%{HTTP_HOST}/ [L,NC]

RewriteCond %{HTTP_HOST} ([^\.]+).forums.cx [NC]
RewriteCond %{HTTP_HOST} !^forums.cx$ [NC]
RewriteCond %{HTTP_HOST} !^www.forums.cx$ [NC]
RewriteCond %{HTTP_HOST} !^forum.forums.cx$ [NC]
RewriteCond %{HTTP_HOST} !^forums.forums.cx$ [NC]
RewriteRule ^(.*)$ http://forums.do/ [L,NC]
http://forums.do/instance/.htaccess
Code:
    # Lines That should already be in your .htacess
    <Files "config.php">
    Order Allow,Deny
    Deny from All
    </Files>
    <Files "common.php">
    Order Allow,Deny
    Deny from All
    </Files>

    # You may need to un-comment the following lines
    # Options +FollowSymlinks
    # To make sure that rewritten dir or file (/|.html) will not load dir.php in case it exist
    # Options -MultiViews
    # REMEBER YOU ONLY NEED TO STARD MOD REWRITE ONCE
    RewriteEngine On
    # Uncomment the statement below if you want to make use of
    # HTTP authentication and it does not already work.
    # This could be required if you are for example using PHP via Apache CGI.
    # RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
    # REWRITE BASE
    RewriteBase /
    # HERE IS A GOOD PLACE TO FORCE CANONICAL DOMAIN
    # RewriteCond %{HTTP_HOST} !^forums\.do$ [NC]
    # RewriteRule ^(.*)$ http://forums.do/forums/$1 [QSA,L,R=301]

    # DO NOT GO FURTHER IF THE REQUESTED FILE / DIR DOES EXISTS
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule . - [L]
    #####################################################
    # PHPBB SEO REWRITE RULES ALL MODES
    #####################################################
    # AUTHOR : dcz www.phpbb-seo.com
    # STARTED : 01/2006
    #################################
    # FORUMS PAGES
    ###############
    # FORUM INDEX REWRITERULE WOULD STAND HERE IF USED. "forum" REQUIRES TO BE SET AS FORUM INDEX
    # RewriteRule ^forum\.html$ index.php [QSA,L,NC]
    # FORUM ALL MODES
    RewriteRule ^(forum|[a-z0-9_-]*-f)([0-9]+)/?(page([0-9]+)\.html)?$ viewforum.php?f=$2&start=$4 [QSA,L,NC]
    # TOPIC WITH VIRTUAL FOLDER ALL MODES
    RewriteRule ^(forum|[a-z0-9_-]*-f)([0-9]+)/(topic|[a-z0-9_-]*-t)([0-9]+)(-([0-9]+))?\.html$ viewtopic.php?f=$2&t=$4&start=$6 [QSA,L,NC]
    # TOPIC WITHOUT FORUM ID & DELIM ALL MODES
    RewriteRule ^([a-z0-9_-]*)/?(topic|[a-z0-9_-]*-t)([0-9]+)(-([0-9]+))?\.html$ viewtopic.php?forum_uri=$1&t=$3&start=$5 [QSA,L,NC]
    # PHPBB FILES ALL MODES
    RewriteRule ^resources/[a-z0-9_-]+/(thumb/)?([0-9]+)$ download/file.php?id=$2&t=$1 [QSA,L,NC]
    # PROFILES ALL MODES WITH ID
    RewriteRule ^(member|[a-z0-9_-]*-u)([0-9]+)\.html$ memberlist.php?mode=viewprofile&u=$2 [QSA,L,NC]
    # USER MESSAGES ALL MODES WITH ID
    RewriteRule ^(member|[a-z0-9_-]*-u)([0-9]+)-(topics|posts)(-([0-9]+))?\.html$ search.php?author_id=$2&sr=$3&start=$5 [QSA,L,NC]
    # GROUPS ALL MODES
    RewriteRule ^(group|[a-z0-9_-]*-g)([0-9]+)(-([0-9]+))?\.html$ memberlist.php?mode=group&g=$2&start=$4 [QSA,L,NC]
    # POST
    RewriteRule ^post([0-9]+)\.html$ viewtopic.php?p=$1 [QSA,L,NC]
    # ACTIVE TOPICS
    RewriteRule ^active-topics(-([0-9]+))?\.html$ search.php?search_id=active_topics&start=$2&sr=topics [QSA,L,NC]
    # UNANSWERED TOPICS
    RewriteRule ^unanswered(-([0-9]+))?\.html$ search.php?search_id=unanswered&start=$2&sr=topics [QSA,L,NC]
    # NEW POSTS
    RewriteRule ^newposts(-([0-9]+))?\.html$ search.php?search_id=newposts&start=$2&sr=topics [QSA,L,NC]
    # UNREAD POSTS
    RewriteRule ^unreadposts(-([0-9]+))?\.html$ search.php?search_id=unreadposts&start=$2 [QSA,L,NC]
    # THE TEAM
    RewriteRule ^the-team\.html$ memberlist.php?mode=leaders [QSA,L,NC]
    # HERE IS A GOOD PLACE TO ADD OTHER PHPBB RELATED REWRITERULES

    # FORUM WITHOUT ID & DELIM ALL MODES
    # THESE THREE LINES MUST BE LOCATED AT THE END OF YOUR HTACCESS TO WORK PROPERLY
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-z0-9_-]+)/?(page([0-9]+)\.html)?$ viewforum.php?forum_uri=$1&start=$3 [QSA,L,NC]
    # FIX RELATIVE PATHS : FILES
    RewriteRule ^.+/(style\.php|ucp\.php|mcp\.php|faq\.php|download/file.php)$ $1 [QSA,L,NC,R=301]
    # FIX RELATIVE PATHS : IMAGES
    RewriteRule ^.+/(styles/.*|images/.*)/$ $1 [QSA,L,NC,R=301]
    # END PHPBB PAGES
    #####################################################
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back