[.htaccess]mod_rewrite won't work.. [Fixed]

Results 1 to 10 of 10
  1. #1
    The Gamma..? EliteGM is offline
    Grand MasterRank
    Jul 2006 Join Date
    NandolandLocation
    4,077Posts

    [.htaccess]mod_rewrite won't work.. [Fixed]

    Hi,

    On my website I use mod_rewrite, but I've transferred it from my own comp to my host.
    So in the correct folder (/public_html/thamob.nl/cms/) I've created a .htaccess file, with:
    Code:
    RewriteEngine on
    
    RewriteRule ^/articles/(.*)/$ /news.php?article=$1
    RewriteRule ^/articles/$ /news.php
    So on my own comp I've just done (almost) the same in httpd.conf in my apache folder, but in my host it needs to be put in a .htaccess

    But this won't work on my host..
    I've contacted the owner but the reply still awaits..

    *EDIT*
    If I try the .htaccess method on my own comp, it doesn't work either.

    Any tips?
    --

    IF YOU EVER HAVE THE SAME PROBLEM OR ALIKE, CHECK THIS FOR A POSSIBLE SOLUTION!!
    Last edited by EliteGM; 18-09-08 at 03:02 PM.


  2. #2
    Hm. foxx is offline
    Grand MasterRank
    Sep 2006 Join Date
    Czech RepublicLocation
    5,256Posts

    Re: [.htaccess]mod_rewrite won't work..

    try
    Code:
    RewriteBase /cms

  3. #3
    The Gamma..? EliteGM is offline
    Grand MasterRank
    Jul 2006 Join Date
    NandolandLocation
    4,077Posts

    Re: [.htaccess]mod_rewrite won't work..

    Didn't work =(

  4. #4
    Grand Master Daevius is offline
    Grand MasterRank
    Jun 2007 Join Date
    NetherlandsLocation
    3,252Posts

    Re: [.htaccess]mod_rewrite won't work..

    Make sure you have the extension called 'mod_rewrite' turned on. If you use WAMP, go to the speed-ish icon in your task bar, left click -> Apache -> Apache Modules -> rewrite_module should be turned on.

  5. #5
    The Gamma..? EliteGM is offline
    Grand MasterRank
    Jul 2006 Join Date
    NandolandLocation
    4,077Posts

    Re: [.htaccess]mod_rewrite won't work..

    Did you get the part that I told this is all on my host, not on my own PC.
    On my own computer i'm 100% that it's on.

    p.s: I use XAMPP.

  6. #6
    Elite Member chrisli75 is offline
    Member +Rank
    Apr 2008 Join Date
    /home/chrisli75/Location
    159Posts

    Re: [.htaccess]mod_rewrite won't work..

    Quote Originally Posted by EliteGM View Post
    Hi,

    On my website I use mod_rewrite, but I've transferred it from my own comp to my host.
    So in the correct folder (/public_html/thamob.nl/cms/) I've created a .htaccess file, with:
    Code:
    RewriteEngine on
    
    RewriteRule ^/articles/(.*)/$ /news.php?article=$1
    RewriteRule ^/articles/$ /news.php
    So on my own comp I've just done (almost) the same in httpd.conf in my apache folder, but in my host it needs to be put in a .htaccess

    But this won't work on my host..
    I've contacted the owner but the reply still awaits..

    *EDIT*
    If I try the .htaccess method on my own comp, it doesn't work either.

    Any tips?
    Try
    Code:
    Options +FollowSymlinks
    RewriteEngine on
    
    RewriteRule ^/articles/(.*)/$ /news.php?article=$1
    RewriteRule ^/articles/$ /news.php

  7. #7
    Grand Master Daevius is offline
    Grand MasterRank
    Jun 2007 Join Date
    NetherlandsLocation
    3,252Posts

    Re: [.htaccess]mod_rewrite won't work..

    "If I try the .htaccess method on my own comp, it doesn't work either."

    Must've misunderstood...
    Then your server has it turned off, probably. If it works somewhere, then the code is correct ;)

  8. #8
    Sorcerer Supreme admLoki is offline
    Member +Rank
    Apr 2005 Join Date
    www.codenetwork.ruLocation
    345Posts

    Re: [.htaccess]mod_rewrite won't work..

    Quote Originally Posted by Daevius View Post
    Then your server has it turned off, probably. If it works somewhere, then the code is correct ;)
    No and no again. If mod_rewrite is off apache will throw a 500 error.

    Try this:
    Code:
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /cms/
    
    RewriteRule ^/articles/(.*)$ news.php?article=$1 [NC,L]
    RewriteRule ^/articles$ news.php [NC,L]

  9. #9
    The Gamma..? EliteGM is offline
    Grand MasterRank
    Jul 2006 Join Date
    NandolandLocation
    4,077Posts

    Re: [.htaccess]mod_rewrite won't work..

    @Daev:
    I'm sure it's turned on because in my public_html there's a htaccess file with mod_rewrite code too, so it redirects everything to the correct map (/~user_name/something.php TO: /~user_name/domain.com/something.php).
    That's an auto-generated file.

    EDIT:
    @AmdLoki:
    Still get a 404 Not Found >(

  10. #10
    The Gamma..? EliteGM is offline
    Grand MasterRank
    Jul 2006 Join Date
    NandolandLocation
    4,077Posts

    Re: [.htaccess]mod_rewrite won't work..

    FIXED IT!

    Looked through and through and found out that:
    Code:
    RewriteEngine on
    
    RewriteRule ^/articles/(.*)/$ /news.php?article=$1
    RewriteRule ^/articles/$ /news.php
    Will look in / which is public_html which will redirect to domain.com/public_html/
    So now this:
    Code:
    RewriteEngine on
    
    RewriteRule ^articles/(.*)/$ news.php?article=$1
    RewriteRule ^articles/$ news.php
    Works!
    I've removed the slashes so it won't look waay back in the root but just in it's current folder.



Advertisement