View RSS Feed

Mert Gökçeimam

[How-to] Move .htaccess rules into httpd.conf from WHM

Rating: 5 votes, 5.00 average.
by , 03-18-2009 at 10:29 PM (20756 Views)
WHM , cPanel is one of the most widely used server control panels. If you are using WHM and you want to move your .htaccess rules to httpd.conf and if you have no knowledge about SSH usage you can use the following guide.

Login to your WHM panel by your root login located at https://www.yourdomain.com:2087

Look for Service Configuration menu and browse for Apache Configuration under Service Configuration menu.


Within Apache Configuration please look for Include Editor


When you click on Include Editor , you'll be given 3 different choices.
  • Pre Main Include
  • Pre Virtual Host Include
  • Post Virtual Host Include

The include we need to use in here is Pre Virtual Host Include . Please choose your apache version within Pre Virtual Host Include dropdown menu and add your .htaccess rules within the editor.


While adding the rules make sure you use your path correctly
Code:
<Directory /your/httpd/docs>
# Comment the following line (add '#' at the beginning)
# to disable mod_rewrite functions.
# Please note: you still need to disable the hack in
# the vBSEO control panel to stop url rewrites.
RewriteEngine On

# Some servers require the Rewritebase directive to be
# enabled (remove '#' at the beginning to activate)
# Please note: when enabled, you must include the path
# to your root vB folder (i.e. RewriteBase /forums/)
#RewriteBase /

#RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com
#RewriteRule (.*) http://www.yourdomain.com/forums/$1 [L,R=301]

RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]

RewriteCond %{REQUEST_URI} !(admincp/|modcp/|cron|vbseo_sitemap)
RewriteRule ^((archive/)?(.*\.php(/.*)?))$ vbseo.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^(admincp|modcp|clientscript|cpstyles|images)/
RewriteRule ^(.+)$ vbseo.php [L,QSA]
</Directory>
You can add different rewrite rules for different folders.

When you are done adding rewrite rules click on Update button and then restart apache
Categories
vBSEO , Staff Blogs

Comments

  1. kevinl's Avatar
    • |
    • permalink
    Great article

    Thanks!
  2. NLP's Avatar
    • |
    • permalink
    Great !
    Thanks dude ..

    this helps many
  3. Ross's Avatar
    • |
    • permalink
    Cheers for this!!!! Just done it and it works like a charm!
  4. frapedopoulos's Avatar
    • |
    • permalink
    Is their a benefit to doing this? If so what is it? Thanks..
  5. Mert Gökçeimam's Avatar
    • |
    • permalink
    Quote Originally Posted by frapedopoulos
    Is their a benefit to doing this? If so what is it? Thanks..
    Yes , it is advised to move .htaccess content to httpd.conf
    Oleg Ignatiuk likes this.
  6. barbaro's Avatar
    • |
    • permalink
    And to do that by ssh plesk please?

    Thanks and best regards
  7. VJGarber's Avatar
    • |
    • permalink
    Mert Abi Türkcesi Yok mu ?
  8. MikeWarner's Avatar
    • |
    • permalink
    Plesk here too, plese help. Thanks.
  9. iNF3RN0's Avatar
    • |
    • permalink
    Nice tutorial worked like a charm!
  10. pagearabia's Avatar
    • |
    • permalink
    thanks i wille abut in my site pagearabia
  11. project-buckfast's Avatar
    • |
    • permalink
    Does this reduce server load?
  12. project-buckfast's Avatar
    • |
    • permalink
    I need some help with this. When I put in <Directory /home/mysite/public_html> I get a synax error in apache when I click update

    Code:
    Sorry, your changes have introduced a syntax error. Please correct the issue.
    
    Error:
    An error occurred while running: /usr/local/apache/bin/httpd -DSSL -t -f /usr/local/apache/conf/httpd.conf Exit signal was: 0 Exit value was: 1 Output was: --- httpd: Syntax error on line 233 of /usr/local/apache/conf/httpd.conf: Syntax error on line 1 of /usr/local/apache/conf/includes/pre_virtualhost_2.conf: /usr/local/apache/conf/includes/pre_virtualhost_2.conf:1: was not closed. ---
  13. Brian Cummiskey's Avatar
    • |
    • permalink
    Blogs aren't monitored for support. you should post any questions in the forum or via ticket.
  14. Mark Hewitt's Avatar
    • |
    • permalink
    Thanks. That worked fine, although I had to translate it, as many of us don't use silly control panels. vi is all you need!
  15. ghostman's Avatar
    • |
    • permalink
    Then we need to rename the .htaccess in the forum root in order to avoid to be considered?
  16. mecho's Avatar
    • |
    • permalink
    after these steps, all rewrite rulesa re working but i couldnt find those added lines in httpd.cnf so question is :

    where those lines have been added exactly and how we can edit if anytime we want to add a extra line to those rules ?

    thanks in advance
    mike101 and webtriangle like this.
  17. mykkal's Avatar
    • |
    • permalink
    I'm curious. What is the benefit to having rewrite rules in the httpd.conf file instead of .htaccess?

Trackbacks

Total Trackbacks 0
Trackback URL: