Results 1 to 5 of 5
  1. #1
    Newbie Affiliate Ian's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,540
    .htaccess redirect
    I made some changes to filenames in a folder like so:

    www.mydomian.com/folder

    I want all users who visited an older link like so:

    www.mydomain.com/folder/file.html

    that no longer exists to go to:

    www.mydomian.com/folder/index.html

    What do I add to my .htaccess file in the root folder to make this happen. Currently, I have a 404 set so when there is no file, it goes to the 404. I want this redirect to only exists in /folder.

    Any ideas?

  2. #2
    Member sendmemybill's Avatar
    Join Date
    August 6th, 2005
    Location
    St-Georges, Québec, Canada
    Posts
    105
    Try that

    RewriteEngine on
    RewriteBase /
    RewriteRule ^folder/file.html /folder/index.html [L]

  3. #3
    Newbie Affiliate Ian's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,540
    hey thanks for the reply. Let me ask this with more info. Instead of pointing every file that no longer exists, can I set a global setting for this folder only? For instance, for this folder only, if file does not exists (ie. 404 error), redirect to the folder's index.html file. At the moment, my 404 redirect in the .htaccess file in the root folder is taking it to another 404 page.

    Hope that made sense.

  4. #4
    Member sendmemybill's Avatar
    Join Date
    August 6th, 2005
    Location
    St-Georges, Québec, Canada
    Posts
    105
    You could keep your 404 redirect in the .htaccess on the root of your server and put an other .htaccess in "/folder/" that override the one in the root folder.

    So keep your .htaccess in the root for general 404 not found pages and put this one in the /folder/ you want:

    ErrorDocument 404 /index.html
    There is maybe a glitch in this idea, let me know!

  5. #5
    Newbie Affiliate Ian's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,540
    Thanks. I did try that before as you coded but mayeb my old school server is not setup properly. It even overode the root .htaccess file. But, when I put in the full URL, it works. Thanks for the tip!

  6. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. url masking using htaccess or php redirect
    By breeke in forum Programming / Datafeeds / Tools
    Replies: 3
    Last Post: April 29th, 2010, 07:48 PM
  2. .htaccess maybe?
    By Kevin in forum Programming / Datafeeds / Tools
    Replies: 2
    Last Post: December 5th, 2006, 10:09 AM
  3. 301 redirect using htaccess question
    By ~Michelle in forum Midnight Cafe'
    Replies: 5
    Last Post: February 26th, 2006, 09:16 PM
  4. .htaccess & 301 Redirect
    By ~Michelle in forum Search Engine Optimization
    Replies: 2
    Last Post: March 11th, 2005, 12:18 PM

Posting Permissions

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