New Posts
Live Radio
Welcome guest, is this your first visit?
  • Login:
TerminalPoker.com Affiliate Program
+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    MPC
    MPC is offline
    Senior Member
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    Canada Eh?
    Posts
    1,377
    Blog Entries
    20
    Feedback Score
    8 (100%)

    Default Another htaccess question

    I have a bunch of files that are php.

    I was able to set them to rewrite without the extension. For example, to access domain.com/example.php you can type domain.com/example/. However, the php path still works and I want to avoid duplicate content. How do I redirect the php path to the non php path? Here's my htaccess:

    PHP Code:
    RewriteEngine On
    RewriteBase 
    /

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond 
    %{REQUEST_FILENAME}\.php -f
    RewriteRule 
    ^([^/]+)/$ $1.php
    RewriteCond 
    %{REQUEST_FILENAME} !-f
    RewriteCond 
    %{REQUEST_FILENAME} !-d
    RewriteCond 
    %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
    RewriteRule (.*)$ /$1/ [R=301,L

  2. #2
    MPC
    MPC is offline
    Senior Member
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    Canada Eh?
    Posts
    1,377
    Blog Entries
    20
    Feedback Score
    8 (100%)

    Default

    I should clarify something. I know I can setup the 301 redirect for each URL with the code below:
    PHP Code:
    RewriteRule ^example\.phphttp://www.domain.com/example/ [R=301,L] 
    But I didn't want to do all of them one by one. Let's say I have 100 of these files, I was hoping for a way to redirect them all with one line of code.

  3. #3
    Senior Member
    My Status
     

    Add as a friend
    Join Date
    May 2009
    Location
    United States
    Posts
    225
    Feedback Score
    4 (100%)

    Default

    Completely untested but:

    PHP Code:
    RewriteRule ^([A-Za-z0-9_-]+)\.phphttp://www.domain.com/$1/ [R=301,L] 

  4. #4
    MPC
    MPC is offline
    Senior Member
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    Canada Eh?
    Posts
    1,377
    Blog Entries
    20
    Feedback Score
    8 (100%)

    Default

    doesn't seem to work. Accoring to firefox, I've somehoew created a redirection loop. Does that mean that I can't redirect a file to it's rewritten version?

    For example, the code below will take domain/file.php and allow the URL to be domain/file/ (in other words, both URLs will work).

    PHP Code:
    RewriteEngine On
    Options 
    +FollowSymlinks
    RewriteBase 
    /
    RewriteRule ^\.htaccess$ - [F]

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

    # Forces a trailing slash to be added
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond 
    %{REQUEST_FILENAME} !-d
    RewriteCond 
    %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
    RewriteRule (.*)$ /$1/ [R=301,L

    Since I don't want the domain/file.php to be active, I add a redirect to domain/file/ in order to avoid duplicate content.

    PHP Code:
    RewriteRule ^file.phpdomain.com/file/ [L,R=301
    After adding this line, if I point my browser to domain/file.php it times out in IE and Firefox says it's looping.

  5. #5
    Senior Member
    My Status
     

    Add as a friend
    Join Date
    May 2009
    Location
    United States
    Posts
    225
    Feedback Score
    4 (100%)

    Default

    Quote Originally Posted by MPC View Post
    doesn't seem to work
    Boooo! Sorry man! I'll give it some more thought. Hopefully someone else can chime in!

    PS: Do you have any rules upstream in the htaccess file that may be executing first?

  6. #6
    MPC
    MPC is offline
    Senior Member
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    Canada Eh?
    Posts
    1,377
    Blog Entries
    20
    Feedback Score
    8 (100%)

    Default

    just edited my response with the full code. There's nothing else in the htaccess.

  7. #7
    PAL's Glenn Beck
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    Chillin' in the Ozarks
    Posts
    2,807
    Blog Entries
    18
    Feedback Score
    22 (100%)

    Default

    I'm pretty sure TPB has something for this he's posted before, hit him on PM

  8. #8
    Formerly TPB
    My Status
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    Wales
    Posts
    666
    Feedback Score
    16 (100%)

    Default

    This is what Cheryle gave to me, I think I may do what you're looking to do.

    PHP Code:
    RewriteCond %{THE_REQUEST} ^.*/index.php
    RewriteRule 
    ^(.*)index.php$ /$[R=301,L


 

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. .htaccess file
    By cfowl087 in forum Poker SEO Forum
    Replies: 7
    Last Post: 04-27-2010, 01:27 AM
  2. htaccess questions
    By Squizzel in forum Wordpress - Web Design - Coding - Technical
    Replies: 1
    Last Post: 03-11-2010, 07:15 PM
  3. .htaccess For Add-on Domains
    By GregW in forum Wordpress - Web Design - Coding - Technical
    Replies: 2
    Last Post: 02-24-2010, 05:51 AM
  4. Need help Urgently! htaccess
    By MPC in forum Wordpress - Web Design - Coding - Technical
    Replies: 12
    Last Post: 08-13-2009, 10:57 AM
  5. htaccess help
    By sirtiner in forum Poker SEO Forum
    Replies: 5
    Last Post: 01-24-2009, 05:54 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
Powered by vBulletin® Version 4.1.5
Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.
SEO by vBSEO 3.6.0
Affiliate Program Consultant