Easy RoR & mod_rewrite...

Discussion in 'Ruby/Rails' started by travisbell, Nov 26, 2007.

  1. travisbell

    travisbell New Member

    Hey guys,

    I have an easy RoR template site setup and would like to apply a
    mod_rewrite rule to redirect some urls to other pages on the site.

    I would like to use the .htacess to do this since the site isn't going
    to be deployed on a LiteSpeed server so I can't use the rewrite tools
    built into the admin interface.

    What do I need to enable/change in the LS admin to start using
    mod_rewrite in my .htaccess?

    Thanks!
  2. mistwang

    mistwang LiteSpeed Staff

    Please checkout the "Allow Override" option for the Rails Context.
  3. travisbell

    travisbell New Member

    Hey.

    I have enabled all of the .htaccess options on the server AND vhost level, including the Rails context but I can't get this to go. I have an empty .htaccess with only, the following 2 lines in it:

    Code:
    RewriteCond %{REQUEST_URI} ^/projects/current-urban/kensington/
    RewriteRule ^/projects/current-urban/kensington/ /projects/current-urban/kensington/overview$1 [R=301,L]
    This should redirect requests for /projects/current-urban/kensington/ to /projects/current-urban/kensington/overview/ no?

    Is there anything else that needs to be enabled?
  4. mistwang

    mistwang LiteSpeed Staff

    Adde "RewriteEngine on" above the two rewrite rules. :)
  5. travisbell

    travisbell New Member

    Hello,

    I did this but to still no avail.

    Would it matter if I am running the server (RoR) in development mode? I can't imagine so...

    Basically, it's like LS is ignoring the .htaccess completely and I am not sure why.

    Thanks for any moire help you can give!

    Cheers,
  6. mistwang

    mistwang LiteSpeed Staff

    Please enable debug logging, see if the .htaccess has been loaded when the directory was accessed by the first.

    Enable the rewrite logging for the vhost, see if the rewrite rule is really what you want.
  7. mistwang

    mistwang LiteSpeed Staff

    I think your rewrite will not work in a .htaccess, as the rewrite base has been cut off first.

    if the .htaccess file is under "projects" directory, you need to use a rewrite rule like, turn on rewrite log, you will get some ideas.


    RewriteRule ^current-urban/kensington/(.*) /projects/current-urban/kensington/overview$1 [R=301,L]

Share This Page