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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool rewrite url to remove php extension question

    Hello,

    I have loads of files with .php extensions. I would like help writing a mod rewrite rule that will remove the .php extension from urls like this:

    mysite.com/mypage.php

    I need to retain the "mypage" and pass that on to a controller somehow.

    mysite.com/view.php?page=mypage

    But here is the catch... I don't want the url to show view.php?page=mypage, but I still want somehow for the view.php file to be loaded with that parameter.

    Can I combine rewrite rules. One to remove the extension, one to pass the parameter to the view.php file, and one to change the url to finally be something like this:

    mysite.com/mypage

    Any ideas?

  • #2
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Got it to work

    Never mind the code below... I thought I had it working but it isn't.

    I need the php extension dropped and then the rest of the filename passed on to view.php as a parameter.



    This doesnt work:
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php
    RewriteRule ^([^/\.]+)/?$ view.php?id=$1 [L]
    Last edited by tegan; 04-28-2009 at 11:38 PM. Reason: I made a mistake that doesnt work....


  •  

    Tags for this Thread

    Posting Permissions

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