1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Installing Apache mod-rewrite module

Discussion in 'EasyApache' started by nicholson, Mar 31, 2008.

  1. nicholson

    nicholson New Member

    Joined:
    Mar 31, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    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. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,288
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Houston, TX
    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. nicholson

    nicholson New Member

    Joined:
    Mar 31, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    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. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,319
    Likes Received:
    8
    Trophy Points:
    38
    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. manuki

    manuki New Member

    Joined:
    Dec 18, 2007
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    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. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,319
    Likes Received:
    8
    Trophy Points:
    38
    You'll need to take up this issue with the Drupal developers.
     
  7. cuongvttt

    cuongvttt Member

    Joined:
    Jun 26, 2008
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    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???:confused:
     
  8. cuongvttt

    cuongvttt Member

    Joined:
    Jun 26, 2008
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    mode_rewrite

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

    cheemin New Member

    Joined:
    Jun 28, 2004
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Hi cuongvttt,

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

    Please advise.

    Thanks.
     
  10. screege

    screege Member

    Joined:
    Aug 11, 2004
    Messages:
    192
    Likes Received:
    0
    Trophy Points:
    16
    Me too I am installing magento but I cannot use the rewrite engine. Any help would be very appreciated.
     
  11. dave9000

    dave9000 Member

    Joined:
    Apr 7, 2003
    Messages:
    891
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    arkansas
    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>
     
  12. netarus

    netarus Member

    Joined:
    Oct 27, 2002
    Messages:
    105
    Likes Received:
    0
    Trophy Points:
    16
    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>
    
     
    #12 netarus, Nov 13, 2008
    Last edited: Nov 13, 2008
  13. cmikelis

    cmikelis New Member

    Joined:
    Mar 24, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    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. cPanelTristan

    cPanelTristan Active Member
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,621
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    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.
     

Share This Page