1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to include ".php" after post name in wordpress

Discussion in 'Content Management' started by indyonline, Jan 7, 2011.

  1. #1
    I'm rebuilding a site for somebody and the site was built in PHP so all the URL's have ".PHP" at the end
    example: mysite.com/postname.php
    SEMrush
    I'm rebuilding the site with wordpress and have entered the--> /%postname% in the permalinks area.
    So How can I get the URL it creates for the page to have the .php at the end?

    Thanks in advance.
     
    indyonline, Jan 7, 2011 IP
    SEMrush
  2. BW1

    BW1 Well-Known Member

    Messages:
    252
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #2
    Just put the .php after the last %

    /%postname%.php
     
    BW1, Jan 8, 2011 IP
  3. indyonline

    indyonline Prominent Member

    Messages:
    4,626
    Likes Received:
    248
    Best Answers:
    2
    Trophy Points:
    335
    #3
    I tried that and it didnt work. I think the .htaccess is changing the url structure.
     
    indyonline, Jan 8, 2011 IP
  4. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Might want to try clearing your browser cache and try again. Theoretically that should work.
     
    Dodger, Jan 10, 2011 IP
  5. indyonline

    indyonline Prominent Member

    Messages:
    4,626
    Likes Received:
    248
    Best Answers:
    2
    Trophy Points:
    335
    #5
    tried that too. didn't work. I even downloaded a new browser (Safari) to try it.
     
    indyonline, Jan 10, 2011 IP
  6. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #6
    It is kind of weird, but I think if you accessed those pages from a different ISP they may appear correctly. Not really positive about that.

    I had this problem when adding some rewrite rules to a project, and had a heck of time getting the rules to stick.

    Eventually, I added this code to the beginning of my functions.php to force WP to reload the rules:

    
    add_filter('init','flushRules');
    
    // Remember to flush_rules() when adding rules
    function flushRules(){
    	global $wp_rewrite;
       	$wp_rewrite->flush_rules();
    }
    
    Code (markup):
    This is something you do not want to leave in the file. Take it out after the rules take hold. As I said, it seemed to work from the machine I was working on & the production copy (after pushing to the server) never had a problem.
     
    Dodger, Jan 10, 2011 IP
  7. indyonline

    indyonline Prominent Member

    Messages:
    4,626
    Likes Received:
    248
    Best Answers:
    2
    Trophy Points:
    335
    #7
    ya, that didn't work either. This is weird. Could it be in the .htaccess?
     
    indyonline, Jan 10, 2011 IP
  8. seafrontsteve

    seafrontsteve Peon

    Messages:
    451
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Is the problem that you are trying to build on top of an existing site?
    A 'real' file in a url (whether xxx.html or yyy.php) will always be shown in preference to one you try to create dynamically.
    If so you first need to delete or rename the oringinal .php files
     
    seafrontsteve, Jan 10, 2011 IP
  9. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I don't think that is the case here. If there were an existing page, it would have shown up in the browser (one would think) with the .php extension.
     
    Dodger, Jan 10, 2011 IP
  10. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Short answer, no. But just in case, can you post that file here?

    And, getting back to what seafrontsteve mentioned ... is this site built on top of an existing site? Want to rule out any interference problems. N'est pas?
     
    Dodger, Jan 10, 2011 IP
  11. indyonline

    indyonline Prominent Member

    Messages:
    4,626
    Likes Received:
    248
    Best Answers:
    2
    Trophy Points:
    335
    #11
    If I go to the url with the .php at the end it redirects to the url with out it.
    I'm thinking it might be the .htaccess but I dont know too much about it.
     
    indyonline, Jan 10, 2011 IP
  12. indyonline

    indyonline Prominent Member

    Messages:
    4,626
    Likes Received:
    248
    Best Answers:
    2
    Trophy Points:
    335
    #12
    Here is the .htaccess file

    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    
    Code (markup):
     
    indyonline, Jan 10, 2011 IP
  13. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Did WordPress generate that? And I take it you still have permalinks set to include the .php extension?
     
    Dodger, Jan 10, 2011 IP
  14. indyonline

    indyonline Prominent Member

    Messages:
    4,626
    Likes Received:
    248
    Best Answers:
    2
    Trophy Points:
    335
    #14
    yes, that was the stock WP one. and yes I still have it set to /%postname%.php
     
    indyonline, Jan 10, 2011 IP
  15. experttalk

    experttalk Member

    Messages:
    220
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #15
    word press plugin for ur requirement
     
    experttalk, Jan 10, 2011 IP
  16. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Do not use that link!!!! They take plugins from WordPress, add a file to them, and redistribute as their own. Beware, they are often not up to date versions either.

    You can check out the Dot html,php,xml etc pages plugin at WordPress.
     
    Dodger, Jan 11, 2011 IP
    indyonline likes this.
  17. seafrontsteve

    seafrontsteve Peon

    Messages:
    451
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Interesting that a whois search on www.wordpress-plugin.org shows the domain registrant lives in Turkey.
    Guess that may be why Wordpress haven't gone after them yet for infringing their trademark?
    I checked a couple of years ago and they are happy for you to use wp... but not 'wordpress' in a domain name
    This site definitely devalues their trade name
     
    seafrontsteve, Jan 11, 2011 IP
  18. BW1

    BW1 Well-Known Member

    Messages:
    252
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #18
    Out of interest try make the extension .html and see if that works
     
    BW1, Jan 11, 2011 IP
  19. indyonline

    indyonline Prominent Member

    Messages:
    4,626
    Likes Received:
    248
    Best Answers:
    2
    Trophy Points:
    335
    #19
    Thanks dodger, that plugin worked.
     
    indyonline, Jan 11, 2011 IP
  20. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Kewl dude! If I have the time, will take a look at the code and see if what made the whole thing tick. Maybe can get around not having to use the plugin, if possible.
     
    Dodger, Jan 11, 2011 IP