www.webdeveloper.com
Results 1 to 3 of 3

Thread: Rewrite PHP extensions to slashes

Hybrid View

  1. #1
    Join Date
    Jun 2005
    Location
    London, UK
    Posts
    191

    Rewrite PHP extensions to slashes

    Are there any foreseeable problems with making a general rule to rewrite all ".php" extensions to "/" to make URLs nicer for users?

  2. #2
    Join Date
    Jun 2005
    Location
    London, UK
    Posts
    191
    I'm talking htaccess, of course... any help here?

  3. #3
    Join Date
    Sep 2004
    Posts
    398
    In a .htaccess file in your document root
    Code:
    Options +FollowSymLinks
    
    RewriteEngine On
    
    # Remove .php.
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteCond %{SCRIPT_FILENAME} -f
    RewriteRule ^(.+)\.php$ /$1/ [R=301,L]
    
    # Add .php back.
    RewriteCond %{DOCUMENT_ROOT}/$1.php -f
    RewriteRule ^(.*[^/])/?$ /$1.php [QSA,L]

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles