Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Remove .php extension from subdomain URLs?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #145630
    asiek
    Participant

    I pretty much want to remove .php from the end of each url in browser address bar and when linking to different pages… I found a post on css-tricks but it didn’t help :( I also used this//

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^([^\.]+)/$ $1.php
    

    but neither worked…

    To be more detailed I created a subdomain. http://example.com/test

    Created a new directory within the subdomained titled “games” http://example.com/test/games

    inside of that directory I created two more directories titled “findnclick” and “1” http://example.com/test/games/findnclick and http://example.com/test/games/findnclick/1

    inside of the “1” directory I have multiple files labeled: index.php start.php + header.php & footer.php

    When I create a link from index.php to start.php the url reads: http://example.com/test/games/findnclick/1/start.php

    Which isn’t attractive at all…

    What code can I place into my .htaccess file to remove the ugly extension from links and address bar url?

    htaccess file

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^test\.example\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.test\.example\.com$
    RewriteRule ^/?$ "http\:\/\/example\.com\/test" [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^([^\.]+)/$ $1.php
    
    #145654
    asiek
    Participant

    @traq I’ve already tried to use “pretty URLs” but when I click the link it directs me to my main website’s home page…

    #145673
    asiek
    Participant

    @traq CMS as in wordpress?
    No. I just uploaded the files through FTP to the subdomain directory:
    /public_html/test/games/findnclick/1
    the url should originally be test.example.com
    but I redirected it to example.com/test

    #145787
    asiek
    Participant

    @traq If I am understanding correctly…then yes I do.

    Full .htaccess file//

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^test\.example\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.test\.example\.com$
    RewriteRule ^/?$ "http\:\/\/example\.com\/test" [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^([^\.]+)/$ $1.php
    
    #145920
    asiek
    Participant

    After adding this//

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^test\.example\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.test\.example\.com$
    RewriteRule ^/?$ "http\:\/\/example\.com\/test" [R=301,L]
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)/?$ $1.php
    

    and changing urls to:
    example.com/test/games/findnclick/1/start

    The link just directs me to my main website’s coming soon page…

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Other’ is closed to new topics and replies.