SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Sep 2008
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    htaccess problem (need your advise for my small problem)

    Dear all,

    i want to make my links appears without extensions (www.example.com/about) instead of (www.example.com/about.php)
    i used this code and it works fine
    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php

    1- but my problem is that i have a folder name contact and a file with the same name (contact.php)

    when i click on the link www.example.com/contact it opens the folder not the html file

    notice that my website is dynamic and i can not add static links on htaccess files.. i just want to check if there is a folder with the same name just open the original php file not the folder.


    2- also for index.php page on my wampserver when i clicked on this link ( http://localhost/trial/index)
    it goes to http://localhost/index/ which is an error.. i want to go to the direct link without removing /trial/

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,117
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by john_zakaria View Post
    just open the original php file not the folder.
    Just move contact.php to your root folder.
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  3. #3
    SitePoint Addict
    Join Date
    Sep 2008
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it is in the root folder but in the root also i have a folder named 'contact' i want when i click on contact menu to go to contact.php not contact folder

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,117
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by john_zakaria View Post
    it is in the root folder but in the root also i have a folder named 'contact' i want when i click on contact menu to go to contact.php not contact folder
    Ah, I see. Perhaps rename the folder then—if you need it at all. What is it used for?
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  5. #5
    SitePoint Addict
    Join Date
    Sep 2008
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no i can not rename the folder or the file coz i have many functions to do, it must be the same..

    please advice

  6. #6
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,645
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    jz,

    My ranting about the EVERYTHING atom hasn't resonated with you yet? What happens when a hacker believes that you're using (.*) for your redirection? They will request the server's password file then something else with a php file extension BECAUSE you didn't restrict your accepted characters. Please use GOOD, tight regex to prevent problems!

    BTW, the problem you're having is that you've enabled Options MultiViews causing Apache to fetch the contact.php file when the directory is requested.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •