hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : VPS Hosting : place rewrite rules in .htaccess to virtual host config
Reply

VPS Hosting Virtual private server discussion and vps hosting solutions. Review VPS hosting providers and offer advice on virtual web hosting solutions. If your service is unavailable, please click here.
Forum Jump

place rewrite rules in .htaccess to virtual host config

Reply Post New Thread In VPS Hosting Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 06-08-2012, 04:14 PM
kurtk kurtk is offline
Junior Guru Wannabe
 
Join Date: Jul 2006
Posts: 38

place rewrite rules in .htaccess to virtual host config


I want to eliminate the overhead of .htaccess by putting these rewrite rules
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
in the virtual host configuration file. Do I just add DOCUMENT_ROOT like this?

Code:
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -s [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -l [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Reply With Quote


Sponsored Links
  #2  
Old 06-08-2012, 09:45 PM
cloudrck cloudrck is offline
Is our children learning?
 
Join Date: Aug 2003
Location: Chicago, IL USA
Posts: 2,491
What overhead are you experiencing? You should be fine with the .htaccess.

__________________
CloudRck.com - Host on CloudRck

Reply With Quote
  #3  
Old 06-08-2012, 11:40 PM
foobic foobic is offline
Community Liaison 2.0
 
Join Date: Feb 2005
Location: Australia
Posts: 5,104
Quote:
Originally Posted by kurtk View Post
in the virtual host configuration file. Do I just add DOCUMENT_ROOT like this?
No, just use the same rules inside the virtualhost container that you would in the .htaccess file. When you're sure it's working, AllowOverride None in the main config file to disable .htaccess altogether.

daejuanj - the config files are read once, on Apache startup. .htaccess files (in the request directory and parent directories) are read on every single request. It's not much of an overhead for one or two rules in one .htaccess file but with larger rule sets or several files it adds up. If you have access to the config files, why not take advantage of it?

__________________
Chris

"Learn from the mistakes of others. You can never live long enough to make them all yourself." - Groucho Marx

Reply With Quote
Sponsored Links
  #4  
Old 06-09-2012, 09:00 AM
cloudrck cloudrck is offline
Is our children learning?
 
Join Date: Aug 2003
Location: Chicago, IL USA
Posts: 2,491
Quote:
Originally Posted by foobic View Post
daejuanj - the config files are read once, on Apache startup. .htaccess files (in the request directory and parent directories) are read on every single request. It's not much of an overhead for one or two rules in one .htaccess file but with larger rule sets or several files it adds up. If you have access to the config files, why not take advantage of it?
I'm aware of this, but like you said, it's not much for simple programming, I think most people over exaggerate their overhead without actually doing benchmarks. You do bring up a point, if I had access to the config files I would use it to.

I was curious if the OP actually knew the amount of overhead it were causing.

__________________
CloudRck.com - Host on CloudRck

Reply With Quote
  #5  
Old 06-10-2012, 11:02 AM
kurtk kurtk is offline
Junior Guru Wannabe
 
Join Date: Jul 2006
Posts: 38
Thanks for the replies. Are you sure about using
Quote:
the same rules inside the virtualhost container that you would in the .htaccess file. When you're sure it's working
According to http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule

Quote:
The most visible change to look out for here is that in VirtualHost (per-server) context the request URI as seen by RewriteRule will start with a / (slash). Conversely in .htaccess or Directory (per-directory) the directory containing the rules, plus a trailing slash, are stripped before the comparison to the pattern.

Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
.htaccess file rewrite rules? sp0oon Web Hosting Lounge 2 03-27-2012 07:10 PM
.htaccess mod rewrite for virtual subdomains not working fazsh Programming Discussion 3 08-01-2011 08:06 AM
Convert .htaccess file to nginx rewrite rules chennaihomie Systems Management Requests 2 07-15-2011 03:31 PM
Problem with suexec + fastcgi + htaccess / htpasswd + virtual host amaltemara Hosting Security and Technology 1 03-26-2011 11:45 PM
Help with .htaccess rewrite rules imoracle Programming Discussion 4 07-12-2008 08:20 PM

Related posts from TheWhir.com
Title Type Date Posted
Host Virtual Expands Cloud Platform with New Location in Seattle Web Hosting News 2013-02-21 10:01:56
Host Virtual Expands Cloud Platform with New Location in Denver Web Hosting News 2013-02-21 09:52:56
Host Virtual Further Expands Cloud Services to Hong Kong Web Hosting News 2013-01-25 10:50:56
Web Hosting Provider Host Virtual Expands Indian Cloud Web Hosting News 2012-12-31 12:13:26
Host Virtual Expands Cloud Service in TelecityGroup London Data Center Web Hosting News 2012-02-02 16:55:29


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?