Results 1 to 14 of 14

Thread: Installing Apache mod-rewrite module

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    3

    Default Installing Apache mod-rewrite module

    Using Cpanel with Apache 2 and PHP 5. I'm trying to install mod-rewrite using the script /scripts/easyapache. The script doesn't show anywhere the mod-rewrite option.

    How can I add mod-rewrite to the apache of cpanel?

  2. #2
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,296
    cPanel/WHM Access Level

    Root Administrator

    Default

    Quote Originally Posted by nicholson View Post
    Using Cpanel with Apache 2 and PHP 5. I'm trying to install mod-rewrite using the script /scripts/easyapache. The script doesn't show anywhere the mod-rewrite option.

    How can I add mod-rewrite to the apache of cpanel?
    mod rewrite is installed by default and cannot be disabled, hence you do not see an option for it. The reason it cannot be disabled as it will adversely affect cPanel functionality that relies upon it to function properly.

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    3

    Default

    So you are saying that the httpd.conf will not show an entry like the following?

    LoadModule rewrite_module modules/mod_rewrite.so

    The mod-rewrite is installed but it will not show up on the conf file or inside the modules directory?

    Regards.

  4. #4
    cPanel Development cPanelKenneth's Avatar
    Join Date
    Apr 2006
    Posts
    4,236
    cPanel/WHM Access Level

    Root Administrator

    Default

    Quote Originally Posted by nicholson View Post
    So you are saying that the httpd.conf will not show an entry like the following?

    LoadModule rewrite_module modules/mod_rewrite.so

    The mod-rewrite is installed but it will not show up on the conf file or inside the modules directory?

    Regards.
    Correct. It is compiled statically into the httpd binary, hence there will not be a LoadModule or AddModule entry for it in httpd.conf

  5. #5
    Registered Member
    Join Date
    Dec 2007
    Posts
    18

    Default

    I have problems using Drupal's clean urls. It seems that because the directive is hidden from the httpd.conf when drupal reads the httpd.conf it doesnt find the line and it thinks that the mod-rewrite is not installed.

    Any solution for this?

  6. #6
    cPanel Development cPanelKenneth's Avatar
    Join Date
    Apr 2006
    Posts
    4,236
    cPanel/WHM Access Level

    Root Administrator

    Default

    Quote Originally Posted by manuki View Post
    I have problems using Drupal's clean urls. It seems that because the directive is hidden from the httpd.conf when drupal reads the httpd.conf it doesnt find the line and it thinks that the mod-rewrite is not installed.

    Any solution for this?
    You'll need to take up this issue with the Drupal developers.

  7. #7
    Registered Member
    Join Date
    Jun 2008
    Posts
    28

    Default mode_rewrite

    Dear friends
    I put my scripts on host with CPANEL,but it does not work.
    I get this errors
    404 Not Found

    The server can not find the requested page:

    210.245.85.141/~phuonghn/sieuraovat/2318_Ban_nha_mat_tien_duong_Luy_Ban_Bich__PTan_thanh__Tan_phu.html (port 80)

    Please forward this error screen to 210.245.85.141's WebMaster.
    Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8b mod_bwlimited/1.4 mod_perl/2.0.4 Perl/v5.8.8 Server at 210.245.85.141 Port 80

    Please help me how can i do???

  8. #8
    Registered Member
    Join Date
    Jun 2008
    Posts
    28

    Default mode_rewrite

    Dear friends
    It works well.
    Thank CPANEL CONTROL and that posts.

  9. #9
    Registered Member cheemin's Avatar
    Join Date
    Jun 2004
    Posts
    5

    Default

    Hi cuongvttt,

    May I know how to did it and which post you refer to ?

    Please advise.

    Thanks.

  10. #10
    Registered Member
    Join Date
    Aug 2004
    Posts
    191

    Default

    Me too I am installing magento but I cannot use the rewrite engine. Any help would be very appreciated.

  11. #11
    Registered Member dave9000's Avatar
    Join Date
    Apr 2003
    Location
    arkansas
    Posts
    891
    cPanel/WHM Access Level

    Root Administrator

    Default

    The easiest way to handle the drupal clean urls is add this to the .htaccess in the base directory of the drupal install and edit to your site settings.

    #
    # Apache/PHP/Drupal settings:
    #

    # Protect files and directories from prying eyes.
    <FilesMatch "\.(engine|inc|info|install|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$">
    Order allow,deny
    </FilesMatch>

    # Don't show directory listings for URLs which map to a directory.
    Options -Indexes

    # Follow symbolic links in this directory.
    Options +FollowSymLinks

    # Make Drupal handle any 404 errors.
    ErrorDocument 404 /index.php

    # Force simple error message for requests for non-existent favicon.ico.
    <Files favicon.ico>
    ErrorDocument 404 "The requested file favicon.ico was not found.
    </Files>

    # Set the default handler.
    DirectoryIndex index.php

    # Override PHP settings. More in sites/default/settings.php
    # but the following cannot be changed at runtime.

    # PHP 5, Apache 1 and 2.
    <IfModule mod_php5.c>
    php_flag magic_quotes_gpc off
    php_flag register_globals off
    php_flag session.auto_start off
    php_value mbstring.http_input pass
    php_value mbstring.http_output pass
    php_flag mbstring.encoding_translation off
    </IfModule>

    # Requires mod_expires to be enabled.
    <IfModule mod_expires.c>
    # Enable expirations.
    ExpiresActive On

    # Cache all files for 2 weeks after access (A).
    ExpiresDefault A1209600

    # Do not cache dynamically generated pages.
    ExpiresByType text/html A1
    </IfModule>

    # Various rewrite rules.
    <IfModule mod_rewrite.c>
    RewriteEngine on

    # If your site can be accessed both with and without the 'www.' prefix, you
    # can use one of the following settings to redirect users to your preferred
    # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
    #
    # To redirect all users to access the site WITH the 'www.' prefix,
    # (http://example.com/... will be redirected to http://www.example.com/...)
    # adapt and uncomment the following:
    # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    # RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
    #
    # To redirect all users to access the site WITHOUT the 'www.' prefix,
    # (http://www.example.com/... will be redirected to http://example.com/...)
    # uncomment and adapt the following:
    # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
    # RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

    # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
    # VirtualDocumentRoot and the rewrite rules are not working properly.
    # For example if your site is at http://example.com/drupal uncomment and
    # modify the following line:
    # RewriteBase /drupal
    #
    # If your site is running in a VirtualDocumentRoot at http://example.com/,
    # uncomment the following line:
    RewriteBase /

    # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !=/favicon.ico
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    </IfModule>
    Dave Browning
    Intersite Technologies
    Greenbrier Ar
    dave@isitetech.com

  12. #12
    Registered Member
    Join Date
    Oct 2002
    Posts
    104

    Post

    Hi Dave,

    Thanks for the great post! However, I think you forgot a " at the end of one your strings:

    Replace:

    Code:
    ErrorDocument 404 "The requested file favicon.ico was not found.
    With:

    Code:
    ErrorDocument 404 "The requested file favicon.ico was not found."
    The final result would be:

    Code:
    #
    # Apache/PHP/Drupal settings:
    #
    
    # Protect files and directories from prying eyes.
    <FilesMatch "\.(engine|inc|info|install|module|profile|test|po |sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|a ll-wcprops|entries|format)$">
    Order allow,deny
    </FilesMatch>
    
    # Don't show directory listings for URLs which map to a directory.
    Options -Indexes
    
    # Follow symbolic links in this directory.
    Options +FollowSymLinks
    
    # Make Drupal handle any 404 errors.
    ErrorDocument 404 /index.php
    
    # Force simple error message for requests for non-existent favicon.ico.
    <Files favicon.ico>
    ErrorDocument 404 "The requested file favicon.ico was not found."
    </Files>
    
    # Set the default handler.
    DirectoryIndex index.php
    
    # Override PHP settings. More in sites/default/settings.php
    # but the following cannot be changed at runtime.
    
    # PHP 5, Apache 1 and 2.
    <IfModule mod_php5.c>
    php_flag magic_quotes_gpc off
    php_flag register_globals off
    php_flag session.auto_start off
    php_value mbstring.http_input pass
    php_value mbstring.http_output pass
    php_flag mbstring.encoding_translation off
    </IfModule>
    
    # Requires mod_expires to be enabled.
    <IfModule mod_expires.c>
    # Enable expirations.
    ExpiresActive On
    
    # Cache all files for 2 weeks after access (A).
    ExpiresDefault A1209600
    
    # Do not cache dynamically generated pages.
    ExpiresByType text/html A1
    </IfModule>
    
    # Various rewrite rules.
    <IfModule mod_rewrite.c>
    RewriteEngine on
    
    # If your site can be accessed both with and without the 'www.' prefix, you
    # can use one of the following settings to redirect users to your preferred
    # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
    #
    # To redirect all users to access the site WITH the 'www.' prefix,
    # (http://example.com/... will be redirected to http://www.example.com/...)
    # adapt and uncomment the following:
    # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    # RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
    #
    # To redirect all users to access the site WITHOUT the 'www.' prefix,
    # (http://www.example.com/... will be redirected to http://example.com/...)
    # uncomment and adapt the following:
    # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
    # RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
    
    # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
    # VirtualDocumentRoot and the rewrite rules are not working properly.
    # For example if your site is at http://example.com/drupal uncomment and
    # modify the following line:
    # RewriteBase /drupal
    #
    # If your site is running in a VirtualDocumentRoot at http://example.com/,
    # uncomment the following line:
    RewriteBase /
    
    # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !=/favicon.ico
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    </IfModule>
    Last edited by netarus; 11-13-2008 at 09:02 AM. Reason: Update to include completely revised .htaccess file

  13. #13
    Registered User
    Join Date
    Mar 2011
    Posts
    1

    Default mod-rewrite issue and php redirect

    Issue example: domainname which contains the following:
    <?php include('domainname/PMWiki/pmwiki.php?n=Organizations.Organizations');
    returns blank unable to redirect properly

    From what I understand to make this work I need to do something with mod_rewrite.
    From this thread, mod_rewrite is supposed to be installed. To confirm I run the command
    "httpd -l | grep mod_rewrite mod_rewrite.c"
    However, it returns: grep: mod_rewrite.c: No such file or directory

    Oddly, when I execute "httpd -l" mod_rewrite.c is in the list
    Compiled in modules:
    core.c
    mod_authn_file.c
    mod_authn_default.c
    mod_authz_host.c
    mod_authz_groupfile.c
    mod_authz_user.c
    mod_authz_default.c
    mod_auth_basic.c
    mod_include.c
    mod_filter.c
    mod_log_config.c
    mod_logio.c
    mod_env.c
    mod_expires.c
    mod_headers.c
    mod_setenvif.c
    mod_proxy.c
    mod_proxy_connect.c
    mod_proxy_ftp.c
    mod_proxy_http.c
    mod_proxy_scgi.c
    mod_proxy_ajp.c
    mod_proxy_balancer.c
    mod_ssl.c
    prefork.c
    http_core.c
    mod_mime.c
    mod_status.c
    mod_autoindex.c
    mod_asis.c
    mod_info.c
    mod_suexec.c
    mod_cgi.c
    mod_negotiation.c
    mod_dir.c
    mod_actions.c
    mod_userdir.c
    mod_alias.c
    mod_rewrite.c
    mod_so.c

    I'm new to cpanel and unsure what I need to do

    Thanks in advance for the help

  14. #14
    cPanel Staff cPanelTristan's Avatar
    Join Date
    Oct 2010
    Location
    somewhere over the rainbow
    Posts
    7,610
    cPanel/WHM Access Level

    Root Administrator

    Default Re: Installing Apache mod-rewrite module

    Add an -i flag to the grep:

    Code:
    httpd -l | grep -i rewrite
    I would not check for the exact string anyway, since it makes more sense to check for a portion of the string in case you aren't fully certain of how Apache names the module. This way you get a greater likelihood of a return.

    Regardless, mod_rewrite is enabled by default and the issue is not that it isn't enabled on a cPanel machine. Have you checked the error logs for the site or Apache on the machine? The Apache error logs are at /usr/local/apache/logs/error_log location. The site's error logs are likely at /home/username/public_html/error_log or wherever the application's home directory is placed.
    cPResources: Support Options | More Support Options | Forums Search | cPanel.net Site Search | Mailing Lists(Alt) | Docs
    -- Tristan, Technical Analyst III, Forums Specialist, cPanel Tech Support

    Submit a ticket | Check an existing ticket

Similar Threads

  1. httpd / apache 2 / mod rewrite
    By Zion Ahead in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 06-04-2008, 08:57 PM
  2. Rewrite Mod
    By Mute in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 11-20-2006, 11:18 PM
  3. Mod rewrite not being used by apache
    By BobbiNGEmu in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 04-01-2005, 04:25 AM
  4. mod rewrite
    By Getox in forum cPanel & WHM Discussions
    Replies: 7
    Last Post: 01-11-2005, 01:50 PM
bargain