#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    76
    Rep Power
    8

    URL Rewriting and duplicate URL


    Hi Friends

    I have a website built in PHP & i changed some of PHP pages to .html ext. using URL Rewriting. everything working fine but now i can access my site using .php as well as .html ext. which is not good for SEO

    this is my rule

    [PHPNET=""]
    Options +FollowSymlinks
    RewriteEngine On

    RewriteRule ^Testimonials/testimonials.html$ Testimonials/testimonials.php
    [/PHPNET]

    to 301 redirect my php page to html i add following code but it not working please help


    [PHPNET=""]Options +FollowSymlinks
    RewriteEngine On

    RewriteRule ^Testimonials/testimonials.php$ Testimonials/testimonials.html[R=301,QSA,L]

    RewriteRule ^Testimonials/testimonials.html$ Testimonials/testimonials.php
    [/PHPNET]
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,072
    Rep Power
    9398
    Don't bother with the URL rewriting: just make the files actual .html files and then use
    Code:
    SetHandler application/x-httpd-php .html
    to make them execute as PHP scripts.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    76
    Rep Power
    8
    Originally Posted by requinix
    Don't bother with the URL rewriting: just make the files actual .html files and then use
    Code:
    SetHandler application/x-httpd-php .html
    to make them execute as PHP scripts.
    thanks for reply.

    i am new with this stuff. can you please explain in more details whet changes i required & how i include this in htaccess
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,072
    Rep Power
    9398
    Put that SetHandler thing in the .htaccess instead of the URL rewriting parts. Then rename your .php files to .html.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    76
    Rep Power
    8
    Originally Posted by requinix
    Put that SetHandler thing in the .htaccess instead of the URL rewriting parts. Then rename your .php files to .html.
    thanks for quick reply.

    but i think this is not helpful for us.

    i have a website which previously running with .php & query string. now using url re-writing we change all PHP pages to HTML as per requirement. now website can be access from both URL & our SEO guys says that its not good for website & we need to redirect all PHp pages to .html pages
  10. #6
  11. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,072
    Rep Power
    9398
    You're changing all your URLs. Your SEO will be screwy for a while.

    Try
    Code:
    RewriteEngine on
    
    # 1. Redirect .php to .html
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_URI} \.php$
    RewriteRule (.*)\.php$ $1.html [L,R=301]
    
    # 2. Rewrite .html to .php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} (.*)\.html$
    RewriteCond %1.php -f
    RewriteRule ^ %1.php [L]
    Note that you still need to fix all your links and forms and whatever to use *.html.

IMN logo majestic logo threadwatch logo seochat tools logo