Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-28-2009, 06:48 AM
Powlo Powlo is offline
 
Join Date: Feb 2008
Location: Sunderland UK
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default htaccess problem

I used to use a portal on my site but i recently removed it so i have been using the following htaccess file to direct all users to my forum. The problem with this is that i can no longer get to my phpmyadmin page which is http://www.mysite.com/phpmyadmin/ as it always changes the url to http://www.mysite.com/forum/phpmyadmin/

RewriteEngine On
RewriteBase /
RewriteRule (.*) http://www.mysite.com/forum/$1 [R,L]

What have i done wrong?
Reply With Quote
  #2  
Old 03-28-2009, 07:03 AM
TigerC10's Avatar
TigerC10 TigerC10 is offline
 
Join Date: Apr 2006
Location: Austin, TX
Posts: 616
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The rewrite rule matches the . character as a wildcard for anything, the * matches 0 or more occurances of the character before it. That's why you're getting that result. It doesn't check for the directory existance at all, it just matches anything and sticks it where you tell it to go.

Honestly, I recommend just removing the /forum subdirectory all together. No muss no fuss, can you dig it? But if you absolutely want to have a subdirectory, then you can easily create an index.php file that redirects instead of using the htaccess.

PHP Code:
<?php
ob_start
();
header("Location: http://www.mysite.com/forum");
ob_end_flush();
?>


I wouldn't advise using htaccess rewrite rules since you'd have to go crazy with manual definitions for any subdirectory you want to add in the future.
Reply With Quote
  #3  
Old 03-28-2009, 07:16 AM
Powlo Powlo is offline
 
Join Date: Feb 2008
Location: Sunderland UK
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks i'll give that a try, i would move my forum back to the main directory but just thinking about all the urls on my site that contain /forum/ just makes me shiver so i think i'll have to keep it.
Reply With Quote
  #4  
Old 03-28-2009, 11:32 AM
snakes1100 snakes1100 is offline
 
Join Date: Dec 2001
Location: Michigan
Posts: 3,733
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

RewriteEngine On
RewriteBase /
RewriteRule (.*) http://www.mysite.com/forum/$1 [R,L]
RewriteCond %{REQUEST_URI} !^/phpmyadmin
RewriteRule ^(.*)$ phpmyadmin/$1 [L]
RewriteCond %{REQUEST_URI} !^/newsubdir
RewriteRule ^(.*)$ newsubdir/$1 [L]

If you want to add more subdir's just adjust the last two lines and rename the phpmyadmin/newsubdir to your new dir name.

As well, htaccess if far more efficient than having php do the redirects for you.
Reply With Quote
  #5  
Old 03-28-2009, 03:47 PM
TigerC10's Avatar
TigerC10 TigerC10 is offline
 
Join Date: Apr 2006
Location: Austin, TX
Posts: 616
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, for the initial redirect you're correct that it's more efficient for the server to do it that way. However, the .htaccess file is checked and parsed for every single page request. The PHP redirect script is only parsed for the initial, not every single request. So ultimately, the .htaccess is not more efficient - and the longer the .htaccess file gets (the more subdirectories added to the exeption list) the less efficient it is.
Reply With Quote
  #6  
Old 03-28-2009, 05:16 PM
snakes1100 snakes1100 is offline
 
Join Date: Dec 2001
Location: Michigan
Posts: 3,733
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That would be based on your opinion or on actual page load testing that you have done?
Reply With Quote
  #7  
Old 03-28-2009, 05:26 PM
TigerC10's Avatar
TigerC10 TigerC10 is offline
 
Join Date: Apr 2006
Location: Austin, TX
Posts: 616
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Consider:

Every single time you load a page from the apache server, you're adding the .htaccess to the program calls. The server has to parse that .htaccess every single time, so the longer it gets the longer it takes to parse. Then it has to go through and compare everything in the request to the values in the .htaccess file. After that, it has to decide what to do based on what it finds. This happens every time you load a page. If apache doesn't find a .htaccess file in the current directory, it goes up a directory and looks in there until it reaches the webroot directory.

It is still more efficient than calling the PHP engine and having it parse the PHP file and then redirectiong, though. That is why the initial http://www.mysite.com/ call is more efficient with .htaccess. However, then the site becomes http://www.mysite.com/forums and it's still parsing and comparing that .htaccess file and its values since there's no .htaccess in the forum directory. Ultimately, that makes the rest of the website run less efficiently.

Using the PHP redirect, you take a slightly heavier hit on the initial request to http://www.mysite.com/, but from there on out when http://www.mysite.com/forums is accessed there's no overhead from the .htaccess file.

One could solve the issue by making a blank .htaccess file in the forums directory, but that's just bad programming practice in my honest opinion.
Reply With Quote
  #8  
Old 03-28-2009, 09:04 PM
snakes1100 snakes1100 is offline
 
Join Date: Dec 2001
Location: Michigan
Posts: 3,733
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, but your opinion is based on what facts/load testing?
Reply With Quote
  #9  
Old 03-28-2009, 09:55 PM
Michael.A's Avatar
Michael.A Michael.A is offline
 
Join Date: Dec 2008
Location: L.A
Posts: 449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?ur site goes here.com/phpmyadmin/$ [NC]
RewriteCond %{REQUEST_URI} !^/phpmyadmin/
RewriteRule ^(.*)$ "http://ur site goes here.com/phpmyadmin/" [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?ur site goes here.com$ [NC]
RewriteCond %{REQUEST_URI} !^/forum/
RewriteRule ^(.*)$ "http://ur site goes here.com/forum/" [R=301,L]
if u want u can do the same for the cpanel http:// ur site goes here.com/capnel/
just add this
Code:
RewriteCond %{HTTP_HOST} ^(www\.)?ur site goes here.com/cpanel/$ [NC]
RewriteCond %{REQUEST_URI} !^/cpanel/
RewriteRule ^(.*)$ "http://ur site goes here.com/cpanel/" [R=301,L]
Reply With Quote
  #10  
Old 03-29-2009, 01:37 AM
TigerC10's Avatar
TigerC10 TigerC10 is offline
 
Join Date: Apr 2006
Location: Austin, TX
Posts: 616
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by snakes1100 View Post
Sorry, but your opinion is based on what facts/load testing?
My opinion was that it's bad programming practice to make a blank .htaccess file to override a superdirectory .htaccess file. Most programmers will tell you that, because you're keeping two sets of books to do something that is largely unnecessary.

You were probably referring to the idea that .htaccess can make a website run less efficiently. That's not an opinion, because I don't believe that magic pixies live in computers to execute instructions without cost. Like it or not, apache checks the .htaccess for every request. If the file exists, it has to do string matching - then it has to do string replacement if it finds a match - then it processes things "normally". If you think this can happen in a server without any cost, no toll on the memory or processor, then you must believe that fairies exist and live in mushrooms. lol

In terms of differences between load, it's negligible. You will not see a difference. But you said it was more efficient to use .htaccess, and that's simply not true. I've done all I can for you, I don't know how to put it any more simply. If you execute more instructions on the server's processor for every page request, it is less efficient.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:52 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04395 seconds
  • Memory Usage 2,256KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete