need htaccess help

Discussion in 'Apache' started by hasbehas, Jan 29, 2007.

  1. #1
    Hi There,

    I need help with my htaccess file for redirecting.

    Under a folder any .htm requested has to redirected to folder index.
    Like ; RedirectMatch 301 folder3/*.htm$ /folder3/

    And also specific htm file requested has to redirected to a php script.
    Like ; RedirectMatch 301 folder3/somefile.htm /folder3/script.php?details=somefilename&m=1&md=sc1

    what would be the way to do it ?
     
    hasbehas, Jan 29, 2007 IP
  2. lookzovt

    lookzovt Peon

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Are requested .htm files exists? If not:

    RewriteCond /phisical/path%{REQUEST_FILENAME} !-s
    RewriteRule ^/folder3/(.+) /folder3/index.htm

    Example:
    You have files: /folder3/index.htm and /folder3/test.htm

    You can request:
    /folder3/index.htm and you got it
    /folder3/test.htm and you got it
    /folder3/nonexist.htm and you got index.htm

    Or if you want to redirect all (if file exist or not):
    RewriteRule ^/folder3/(.+).htm /folder3/

    I think... not tested :) Based on VirtualHost directive, but i think in .htaccess can work.
     
    lookzovt, Jan 29, 2007 IP
  3. hasbehas

    hasbehas Well-Known Member

    Messages:
    726
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    190
    #3
    Actually, some htm files would exist and some would not. This is why I wanted redirect. Engines will have to update the links..
    Redirect....
     
    hasbehas, Jan 29, 2007 IP
  4. hasbehas

    hasbehas Well-Known Member

    Messages:
    726
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    190
    #4
    No suggestions..??
     
    hasbehas, Feb 1, 2007 IP
  5. modulesoft

    modulesoft Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Sir i have a very simple question
    i have a website
    and its in php
    i have use the redirect engine to show extension as html insteade of php


    but in my site all links and stuff r in php
    and its now hard to chaneg each link to html

    so can u let meknow how to do that in htaccess here is my htaccess code


    Options +FollowSymLinks

    RewriteEngine On

    RewriteRule ^([^.]+).html$ /$1.php [QSA,L]



    its work fine
    if some one type mysitename.com/index.php works
    and mysitenamev.com/index.html works fine

    but i want when a type .php so it iwll automatically redirect to respective html file

    please help me asap
     
    modulesoft, Feb 7, 2007 IP
  6. hasbehas

    hasbehas Well-Known Member

    Messages:
    726
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    190
    #6

    in htaccess I have

    
    RewriteEngine On
    RewriteBase /
    RewriteRule ^([^/]+)/$ details.php?content=$1 [L]
    
    Code (markup):
    to make the urls
    from domain.com/details.php?content=aboutus
    to domain.com/aboutus

    it does not work.

    I had
    RewriteRule ^/(.+) /details.php?content=$1
    Code (markup):
    before.. didnt work either.. :(
    Any idea why ?
     
    hasbehas, Feb 18, 2007 IP
  7. hasbehas

    hasbehas Well-Known Member

    Messages:
    726
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    190
    #7
    sorted now..
     
    hasbehas, Mar 17, 2007 IP