Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    141
    Thanks
    3
    Thanked 1 Time in 1 Post

    help mod rewrite .php to nothing

    guys.


    any htaccess script to remove something like

    localhost/contact.php .

    to localhost/contact

    (stripped off the .php )


    and do i need to change all link in something.php to something ?

    that would be a little inconvenient but any other thoughts ?

    thanks

  • #2
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    Please ask a mod to move this to the new Apache configuration forum.

    BTW try this:

    Code:
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(about|contact|index|welcome|info)\.php\ HTTP/ [NC]
    RewriteRule .* http://www.YOURSITE.com/%1 [R=301,QSA]
    
    RewriteRule ^(about|contact|index|welcome|info)/? /$1.php [QSA,L]
    replace about contact index welcome.... with your files you want to do and replace YOURSITE with your site name...
    Last edited by sea4me; 05-21-2009 at 11:33 PM.

  • #3
    Regular Coder
    Join Date
    Apr 2007
    Posts
    141
    Thanks
    3
    Thanked 1 Time in 1 Post
    hi thank you for moving this thread to the right one . .. never thought this thread exists... i ll try ur suggestion tonight thanks

  • #4
    Regular Coder
    Join Date
    Apr 2007
    Posts
    141
    Thanks
    3
    Thanked 1 Time in 1 Post
    sea4me

    actually i didn't work for me . i am not sure why..


    i only have pages like about contact gallery and so on ...

    each of them are in .php extension

    i just wanted to remove the .php ... so you can see it like
    localhost/contact

    localhost/about

    and of source after development it will be deployed on www.something.com/contact.

    which i could just change the YOURSITE.com from localhost to something.com right ? but anyway it does not work on localhost....

    any advice? thanks

  • #5
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    did u turn on rewrite engine?

    Code:
    Options +FollowSymLinks
     
    RewriteEngine On
    RewriteBase /

  • #6
    Regular Coder
    Join Date
    Oct 2004
    Posts
    330
    Thanks
    0
    Thanked 13 Times in 13 Posts
    actually i didn't work for me . i am not sure why..
    What happens when you go to /contact?

    Try
    Code:
    Options +FollowSymLinks
    
    RewriteEngine On
    
    RewriteCond %{THE_REQUEST} \ /(about|contact|index|welcome|info)\.php(\?.*)?\  [NC]
    RewriteRule . /%1 [R=301,L]
    
    RewriteRule ^(about|contact|index|welcome|info)/? /$1.php [QSA,L]

  • #7
    New Coder
    Join Date
    Feb 2008
    Posts
    55
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I'm still not changed following the yours

  • #8
    Regular Coder
    Join Date
    Oct 2004
    Posts
    330
    Thanks
    0
    Thanked 13 Times in 13 Posts
    What happens when you go to /contact? Do you get a 404 error?

    If you put the following in your .htaccess file
    Code:
    Options +FollowSymLinks
    
    RewriteEngine On
    
    RewriteRule cf http://codingforums.com/? [R=301,L]
    and go to /cf, do you get redirected to CodingForums?

  • #9
    New Coder
    Join Date
    Feb 2008
    Posts
    55
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Try this one:

    Options +FollowSymLinks

    RewriteEngine On

    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^contact\.php$ /contact [NC,R=301,L]

    RewriteRule ^contact$ /contact.php [NC,QSA,L]
    RewriteRule ^contact/([^/]+)/?$ contact.php?ID=$1 [QSA,L]
    For mine that's worked.

    Regards,
    D


  •  

    Posting Permissions

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