Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2005
    Location
    Argentina
    Posts
    217

    Quick mod_rewrite question

    I would like to extract the extension from every URL ending with .php5 and make a 301 redirect if people access it with .php (eg. www.domain.com/file.php5 to www.domain.com/file).

    What code should I use to accomplish that? Does anyone know?
    DuplikaHosting en Argentina made with love
    Trusted by more than 4000 customers since 2005.

  2. #2
    Join Date
    Jan 2006
    Location
    Athens, Greece
    Posts
    1,479
    I think something like
    RewriteCond %{REQUEST_FILENAME} ^(.*)\.php5$ [NC]
    RewriteRule ^(.*)\.php5$ $1.php [R=301,L]

    Documentation has a better example:

    http://httpd.apache.org/docs/2.2/rew...ite_guide.html

    Scroll to section "Backward Compatibility for YYYY to XXXX migration"
    Last edited by Steve_Arm; 01-25-2008 at 09:27 AM.

  3. #3
    Join Date
    Mar 2005
    Location
    Argentina
    Posts
    217
    Thanks for your reply Steven.

    I've tried that code but it didn't work. If I tried to visit www.domain.com/file.php5, I was redirected to http://www.domain.com/home/username/..._html/file.php.

    Right now what I'm doing is using a file like the following for each file I'd like to translate.

    Code:
    RewriteRule ^filename$ filename.php [L]
    While this gets the job done, it makes the .htaccess bigger and bigger and it doesn't make a 301 redirect if someone goes to the filename.php directly.

    Any help will be greatly appreciated.
    DuplikaHosting en Argentina made with love
    Trusted by more than 4000 customers since 2005.

Posting Permissions

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