NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page htaccess issues, bane of my existance

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Reply
 
LinkBack Thread Tools
Old 04-06-2011, 11:48 PM THREAD STARTER               #1 (permalink)
 
BillyConnite's Avatar
Join Date: Jul 2005
Location: Coffs H, Australia
Posts: 3,456
BillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond repute
 


Wildlife Parkinson's Disease Parkinson's Disease

htaccess issues, bane of my existance


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/.
????: NamePros.com http://www.namepros.com/programming/709992-htaccess-issues-bane-of-my-existance.html

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

Rhett.
Last edited by BillyConnite; 04-08-2011 at 04:46 AM.
BillyConnite is offline   Reply With Quote
Old 04-08-2011, 04:50 AM THREAD STARTER               #2 (permalink)
 
BillyConnite's Avatar
Join Date: Jul 2005
Location: Coffs H, Australia
Posts: 3,456
BillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond repute
 


Wildlife Parkinson's Disease Parkinson's Disease
Hey all,

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

So i'm BUMPING it , 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
    #####################################################
BillyConnite is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ask] HtAccess rewrite for clean url xrvel Programming 1 12-23-2007 11:29 PM
Domain Hop Issues xclusive Domain Name Discussion 4 11-12-2004 02:38 PM
LOWEST magazines prices EVER!! mantra For Sale / Advertising Board 2 10-11-2004 05:53 AM
Legal Issues with certain names... Darren Domain Name Discussion 9 12-11-2003 10:28 AM
Security Issues (BE AWARE) Mp)Tarh Web Design Discussion 3 08-08-2003 02:54 PM

 
All times are GMT -7. The time now is 02:45 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger