The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

mod rewrite problem

Discussion in 'General Discussion' started by asmithjr, Jan 6, 2006.

  1. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    I cannot get something like this to work in my .htaccess.

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule index-id-(.*)\.htm$ index.php?id=$1

    I used the tool from http://www.webconfs.com/url-rewriting-tool.php

    I tried this on 2 servers.

    Now, this does work ( great 301 redirect )

    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^domainname.com [NC]
    RewriteRule ^(.*)$ http://www.domainname.com/$1 [L,R=301]

    the first example, I removed everything in the .htaccess file and it does not work as I just posted.

    I checked the httpd.conf file and have:
    grep mod_rewrite /etc/httpd/conf/httpd.conf

    gave me:

    LoadModule rewrite_module libexec/mod_rewrite.so
    AddModule mod_rewrite.c

    plus a load of containers:

    <IfModule mod_rewrite.c>

    Any ideas? really want to make a search engine friendly URL from
    this http://www.domainname.com/index.php?id=1

    to this: http://www.domainname.com/index-id-1.htm
     
  2. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    this does not work either, something basic

    Options +FollowSymLinks
    RewriteEngine on
    #index
    RewriteBase /
    Rewriterule ^index.html index.php
     
  3. amal

    amal Well-Known Member

    Joined:
    Nov 22, 2003
    Messages:
    155
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    cPanel Access Level:
    Root Administrator
    hmm, same problem here.. latest update seems to have caused problems with mod_rewrite module
     
  4. madmac

    madmac Well-Known Member

    Joined:
    Jan 11, 2004
    Messages:
    61
    Likes Received:
    0
    Trophy Points:
    6
    I've got a problem now that mod_rewrite will not work on IP-less accounts. It works fine on all IP based domains, but it has stopped working on all ip-less accounts.

    I'm scanning httpd.conf to see if I can find it, but so far there is nothing out of the ordinary.
     
  5. web12

    web12 Well-Known Member

    Joined:
    Nov 20, 2002
    Messages:
    240
    Likes Received:
    0
    Trophy Points:
    16
    Hi

    Did someone confirm this as an issue?

    I am currently looking into a problem similar to this on a clients server... very confusing.

    regards
     
  6. rushman

    rushman Active Member

    Joined:
    Sep 21, 2003
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    Same here, rewrite on a subdomain isn't working either using very simple rewrite rules. At this time I can't confirm it is only on subdomains, but it looks that way now.
     
  7. rushman

    rushman Active Member

    Joined:
    Sep 21, 2003
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    Ok, I just confirmed, it works for www.domain.com/subdomain but not subdomain.domain.com

    I'll keep looking into httpd.conf to see what I can find, but would rather someone from cpanel fill us in ;)
     
  8. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    Still nothing on this, I've tried recompiline apache again and also doing a cpanel update.

    seems mod rewrite not working as advertised.
     
  9. 4u123

    4u123 Well-Known Member
    PartnerNOC

    Joined:
    Jan 2, 2006
    Messages:
    765
    Likes Received:
    1
    Trophy Points:
    18
    I can confirm that we are having the same problem.
     
  10. rushman

    rushman Active Member

    Joined:
    Sep 21, 2003
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    Now I want to clear something up and see if the rest of you are seeing the same thing.

    This problem SO FAR, has only happened to me when using gallery 2. Has anyone here had this problem with something other than gallery?
     
  11. 4u123

    4u123 Well-Known Member
    PartnerNOC

    Joined:
    Jan 2, 2006
    Messages:
    765
    Likes Received:
    1
    Trophy Points:
    18
    For me the problem was that the customer with the issue was on a fixed IP and there was no
    entry under the virtualhost setting for that IP as follows...

    <IfModule mod_rewrite.c>
    RewriteEngine on
    </IfModule>
     
  12. ee99ee

    ee99ee Well-Known Member

    Joined:
    Aug 15, 2003
    Messages:
    70
    Likes Received:
    0
    Trophy Points:
    6
    Okay I'm having problems too, on two servers.

    Here is what I've tried:

    Code:
    RewriteEngine on
    RewriteRule ^/foobar$ /test/index.php?id=40
    I just get a 404 when I go to http://mysite/foobar. I've also tried putting Options +FollowSymLinks in the VirtualHost block for the domains I'm testing this on... what gives??

    -Chris
     
  13. Rooter

    Rooter Well-Known Member

    Joined:
    Apr 23, 2003
    Messages:
    146
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, Texas, U.S.A.
    cPanel Access Level:
    Root Administrator
    It looks like you are mixing up redirects and rewrites.

    Try this instead:
    Code:
    RedirectMatch ^/foobar$ /test/index.php?id=40
    ...or possibly:
    Code:
    Redirect ^/foobar$ /test/index.php?id=40
    You might have to input the full URL before the directory structure such as: "http://domain.tld/test/index.php?id=40"

    P.S. To the best of my knowledge, symbolic links have nothing directly to do with Apache redirects and rewrites.
     
    #13 Rooter, Mar 28, 2006
    Last edited: Mar 28, 2006
  14. ee99ee

    ee99ee Well-Known Member

    Joined:
    Aug 15, 2003
    Messages:
    70
    Likes Received:
    0
    Trophy Points:
    6
    Okay, the redirect worked. But that doesn't do exactly what I want to do... I don't want to redirect the user, I don't want them to see the weird URL that their friendly URL points to. How do I do it without a redirect?

    -Chris
     
  15. JimboJ40

    JimboJ40 Active Member

    Joined:
    Jul 10, 2005
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    6
    I got same issue on one of my servers ...

    other one is working fine... anyone got any answers ?
     
  16. apodigm

    apodigm Well-Known Member

    Joined:
    May 12, 2003
    Messages:
    67
    Likes Received:
    0
    Trophy Points:
    6
    same problem.

    It has to do with the Options FollowSymLinks.

    I'm trying to see if that needs to be enabled in the apache config, but that is the only command I need to comment in order to get my sites to work.
     
  17. tenaciousJ

    tenaciousJ Member

    Joined:
    Dec 18, 2003
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Pretty much same issue here. Rewrite is no longer working.
     
  18. apodigm

    apodigm Well-Known Member

    Joined:
    May 12, 2003
    Messages:
    67
    Likes Received:
    0
    Trophy Points:
    6
    I've been able to get a few sites working.

    Things to look for:

    Options +FollowSymLinks
    (make sure you have the leading + sign

    RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
    (On this type of rule, I noticed that I needed the leading slash before the index.php on some sites

    The last thing I've found I don't really know how to solve. I've got some sites with search engine friendly URLs that post the get vars as a path like:
    www.example.com/index.php/option/value/option2/value2

    on these sites, it doesnt work if I include the index.php in the URL...
    so... these two will work:
    www.example.com/option/value/option2/value2
    www.example.com/index.php?option=value&option2=value2

    For troubleshooting, here some things you can do. in httpd.conf in the virtual host area for that website you can add these commands:
    RewriteLog "/path/logfile.log"
    RewriteLogLevel 9
    (change the path filename to wherever you want the logfile.
    The log file is complicated to understand, but it might help you.

    If anyone can help with some .htaccess commands to help with the scenario above that would be great. I've poured over so many sites and references that I'm not even sure I learned much. some areas suggest this is a known bug with PHP/Zend. But in my opinion this has more to do with the .htaccess and Apache environment.
     
  19. tenaciousJ

    tenaciousJ Member

    Joined:
    Dec 18, 2003
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    This seems to have started after this last batch of updates. I havent touched anything, but it seems like for the time being my whole site is shot. I'll take a look at the suggestions you tried and see what happens. Thanks
     
  20. Maximiliam

    Maximiliam Well-Known Member

    Joined:
    Feb 24, 2002
    Messages:
    57
    Likes Received:
    0
    Trophy Points:
    6
    Any update on this ??
     
Loading...

Share This Page