.htacess not being executed

Discussion in 'Apache' started by midnightsun, Oct 15, 2008.

  1. #1
    Dear Forum,

    I need your advise with regards of my problem below. I have Apache 2.2.8 and Tomcat 5.5 running on different boxes (solaris environment). And I would like to do SSL redirection. When I configured the RewriteRule in httpd.conf file, it works perfectly. However, when I configured the RewriteRule using .htaccess file and place it to the document root, it doesn't work at all.

    RewriteLog messages showed that it never read the rule in .htaccess file. (in httpd.conf file, I have rule for tomcat which processing specific extension such as .do or .jsp file).

    Below is my rewrite rule in .htaccess file:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /
    RewriteCond %{HTTP:ssl} !^true$
    RewriteRule ^\/jp\/login(.+)? https://www.abc.com/jp/login$1[R]
    RewriteCond %{HTTP:ssl} !^true$
    RewriteRule ^\/jp\/inquiry(.+)? https://www.abc.com/jp/inquiry$1 [R]
    RewriteCond %{HTTP:ssl} !^true$
    RewriteRule ^\/ja_jp(.+)? https://www.abc.com/ja_jp$1 [R]
    RewriteCond %{HTTP:ssl} !^true$
    RewriteRule ^\/jp\/user(.+)? https://www.abc.com/jp/user$1 [R]
    RewriteCond %{HTTP:ssl} !^true$
    RewriteRule ^\/jp\/present(.+)? https://www.abc.com/jp/present$1 [R]

    Thank you very much in advance, all the responses will be very much appreciated.

    reg,
    MidnightSun.
     
    midnightsun, Oct 15, 2008 IP
  2. Ladadadada

    Ladadadada Peon

    Messages:
    382
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You may need this in the httpd.conf file if it isn't there already:
    AllowOverride All
    Code (markup):
    This is what allows .htaccess files to work.

    Also, in .htaccess files, rewrite rules don't need a leading slash. You should either remove the leading slash or put a question mark after it.

    Lastly, slashes have no special meaning in Apache regular expressions so they don't need escaping. This won't affect how they work but it can make your rewrite rules easier to read.
     
    Ladadadada, Oct 16, 2008 IP
  3. midnightsun

    midnightsun Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hi Ladadadada,

    I really appreciate your reply. For your information, i have found the resolution for this problem. .htaccess file was actually being processed by apache, but since i have my RewriteRule for .do in the config file which was served by Tomcat, the rule in .htaccess file was ignored.

    Therefore i need to copy the RewriteRule in my config file and put them in .htaccess file together.

    Thank you very much.

    reg,
    MidnightSun
     
    midnightsun, Oct 16, 2008 IP