not woking with mod_rewrite!

Discussion in 'Apache' started by greendesert, Mar 10, 2006.

  1. #1
    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^check\.html$ check.php [T=application/x-httpd-php,L]
    /////////////////////////////////////////////////////////////////////////////
    I have 2 files index.php & check.php in the folder test on the ftp server.
    The index.php file has the link on the page like
    <a href="check.php">Click here</a>
    when i access the index.php file on the server by writing www.abc.com/test/index.php in the address bar, the index.php file opens but in the address bar the address remains same as index.php instead index.html.
    when i click on the link to go on the check.php, the check.php file opens but the address in the address bar remains same check.php instead check.html.

    How it is possible these files open with .php extensions but in the address bar the addresses showed as .html extension.
    For this i am using the above code, but is not working to show .html extension in the address bar.
    thanks, it is small and easy task but hard for me.
     
    greendesert, Mar 10, 2006 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Because you link to check.php, there for it shows up as check.php!
     
    Nintendo, Mar 11, 2006 IP
  3. greendesert

    greendesert Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes, i have that link, but is there is any solution for this.
    thanks.
     
    greendesert, Mar 11, 2006 IP
  4. Jean-Luc

    Jean-Luc Peon

    Messages:
    601
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Not sure I understand what you try to do...:confused:

    With your .htaccess, when you type ....../check.html in the address bar, I guess that you open check.php. When you type ....../check.php in the address bar, the .htaccess does not change anything and you also open check.php. As it is now, that's all what your .htaccess does.

    You could redirect from check.php to check.html. Then, when you type check.php, the server will display check.html in the address bar and open check.html (not check.php).

    Jean-Luc
     
    Jean-Luc, Mar 11, 2006 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #5
    If you want to get check.html, you have to link to that page. mod-rewrite doesn't make you link to a different page, it only makes the URL work. Change the link to....

    <a href="check.html">Click here</a>
     
    Nintendo, Mar 11, 2006 IP
  6. greendesert

    greendesert Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    HI,

    Thanks for ur help.
    Actually i have a small website, that has login,logout,contactus,registeration links.
    whenever i clicks on the contactus, the new page contactus.php opens and address bar shows the address as www.abc.com/contactus.php, but i want that the address bar showed the address as www.abc.com/contactus
    Then what will be the rewrite code for this.

    Thanks in advance.
     
    greendesert, Mar 12, 2006 IP
  7. greendesert

    greendesert Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi,

    Is it possible to our updated .htaccess & other files on our local system rather than on FTP server.
    I listened that, some extra modules are required for this to install on your local system, but don't know. If you know kindly help me to install this. I will be very thankful to you for this.

    Thanks
     
    greendesert, Mar 13, 2006 IP
  8. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #8
    Arg!!!! mod_rewrite doesn't change URLs, it only makes the URLs work. If you can't make the link be what ever you want it, then mod_rewrite won't work. E-mail the crummy web host..or even better....get a new one!!!!
     
    Nintendo, Mar 13, 2006 IP
  9. greendesert

    greendesert Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    HI,
    I think, u can use these to convert the .php extensions to .html, rather these files populate from hyper refrence in the form of
    <a href="index2.php">click here for file2</a>, this file opens but the address bar will show the address as www.abc.com/index2.html
    ////////////////////////////////////////////////////////////////////////////////////
    RewriteEngine On
    RewriteCond %{ENV:REDIRECT_STATUS} !^200$
    RewriteCond %{REQUEST_URI} ^(.+)\.php$
    RewriteRule .* %1.html [R,L]
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteRule ^(.+)\.html$ $1.php [L]
    ////////////////////////////////////////////////////////////////////////////////////
    Now i am asking that what are the apache's extra modules with the help of which we can run over .htaccess & and other files on our local system rather than uploading on the FTP server.

    Thanks in advance for your response.
     
    greendesert, Mar 13, 2006 IP
  10. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #10
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)\.php$ http://www.domain.com/$1.html [R=301,L]
     
    Nintendo, Mar 13, 2006 IP
    yfs1 likes this.
  11. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #11
    er...except to do that, the whatever.html page has to exist.

    Do you have SSI? Try index.shtml with just

    <!--#include virtual="/whatever.php" -->

    in it.
     
    Nintendo, Mar 13, 2006 IP