remove ?PHPSESSID=.... from URL

Discussion in 'PHP' started by thosecars82, Oct 3, 2008.

  1. #1
    Hello there

    I am just realizing that first time I enter into http://www.arreglaordenador.com and try to click on any of the header links like "Inicio", "Servicios", "Contacto", or "Acerca de mi" I see a really long dynamic url containing the url itself followed by ?PHPSESSID= .......................... where those ...... symbolize a string of chars

    I have to say that this second dynamic part consisting of PHPSESSID=..... does not appear from the second click in one of those header links. But it does appear on the first click in any of those links.



    The thing is that I heard that dynamic urls are bad for search engines to crawl at them and then I thought that I might do something to avoid this dynamic url since search engines has not been very keen on this site so far.

    The thing is that I am using the sessions to keep the state of an email that might have been started by the user in the Contact page. That way if the user leaves that contact page but comes back later, he would find the text written as he left it instead of having to write the email from the beginning.

    Thank you very much.
     
    thosecars82, Oct 3, 2008 IP
  2. singh.ajit05

    singh.ajit05 Peon

    Messages:
    83
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you can .htaccess file. hide extra information from URL..
     
    singh.ajit05, Oct 3, 2008 IP
  3. thosecars82

    thosecars82 Member

    Messages:
    81
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    Hello again
    The thing is that I do not have any idea about what you say. They only idea I have is changing the dynamic url ?language=sp or ?language?en to a static one by doing something like this:

    # Enable mod_rewrite, start rewrite engine
    Options +FollowSymLinks
    RewriteEngine on
    #
    # Internally rewrite search engine friendly static URL to dynamic filepath and query
    RewriteRule ^language/([^/]+)/?$ /home.php?language=$1 [L]
    #
    # Externally redirect client requests for old dynamic URLs to equivalent new static URLs
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /home\.php\?language=([^&]+)\ HTTP/
    RewriteRule ^home\.php$ http://arreglaordenador.com/language/%1? [R=301,L]
    I just thought about this which by the way I do not know if has some syntax error. Anyways, I thought this would make the url dynamic as for the ?language=en or ?language=sp is concerned. But I would not know how to change the .htaccess file to make that ?PHPSESSID=... static.
    Thanks again for the replies.
     
    thosecars82, Oct 3, 2008 IP
  4. thosecars82

    thosecars82 Member

    Messages:
    81
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #4
    Indeed, as for making the string ?PHPSESSID=... a static url, I still do not know what to do. Moreover, as for the code for inserting into the .htaccess file which I mentioned in my previous post, I have just tested it and it makes my site does not work making the browser throw a Error 500 server error!
    Any suggestion?
    Thanks
     
    thosecars82, Oct 3, 2008 IP
  5. HitManager

    HitManager Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    add to your .htaccess

    php_value session.use_trans_sid 0
     
    HitManager, Oct 3, 2008 IP
  6. thosecars82

    thosecars82 Member

    Messages:
    81
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #6
    It's funny because I tested the site in my local installation after inserting
    php_value session.use_trans_sid 0
    into the .htaccess file and it did work as I expected, that is to say, making the ?PHP_SESSID=... string disappear. However, after uploading the modified file into the server, I
    get this error:

    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Do you have any suggestin to make it work in the server?
    Thanks
     
    thosecars82, Oct 3, 2008 IP
  7. thosecars82

    thosecars82 Member

    Messages:
    81
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #7
    Well, I wrote this to my hosting company:

    "I just wanted to ask whether you have the mod_rewrite module enabled in Apache's httpd.conf file. It is just because I need to insert this line
    php_value session.use_trans_sid 0
    into the .htaccess file of my root folder in your server. I want to add this line to the .htaccess file in order to remove the annoying ?PHP_SESSID=.... from my URL because that dynamic part makes the site less friendly for search enginer. To make the site work by inserting this sentence into the .htaccess file and not getting an error through the browser I would appreciate if you could enable the mod_rewrite module in Apache's httpd.conf file.
    Look forward to seeing your reply really soon.
    Thanks in advance"

    and they told me this:

    "Hello,

    Thank you for contacting our Technical Support Department.

    I have contact our administrators for your question and I am afraid that you will be not able to use this directive on our servers."

    Do you know if I have any other viable alternative to remove the ?PHPSESSID=... from the URL?
    Thanks in advance
     
    thosecars82, Oct 3, 2008 IP
  8. thosecars82

    thosecars82 Member

    Messages:
    81
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #8
    Well, at least, this code
    <?php
    ini_set("url_rewriter.tags","");
    session_start();
    ...
    removed the ?PHPSESSID=... string from my URL as I wanted.
    Nonetheless, if you had some suggestion to change the url which ends in ?language=sp into a static url I would appreciate it because the code I wrote before for the .htaccess, that is to say:
    
    # Enable mod_rewrite, start rewrite engine 
    Options +FollowSymLinks 
    RewriteEngine on 
    # 
    # Internally rewrite search engine friendly static URL to dynamic filepath and query 
    RewriteRule ^language/([^/]+)/?$ /home.php?language=$1 [L] 
    # 
    # Externally redirect client requests for old dynamic URLs to equivalent new static URLs 
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /home\.php\?language=([^&]+)\ HTTP/ 
    RewriteRule ^home\.php$ http://arreglaordenador.com/language/%1? [R=301,L] 
    
    Code (markup):
    not only did not do the trick but it made the browser returned an error.
    Thanks for all your help anyways.
     
    thosecars82, Oct 3, 2008 IP
  9. thosecars82

    thosecars82 Member

    Messages:
    81
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #9
    Thank you. It eventually worked by removing the Options +FollowSymLinks sentence which was causing the error. Now I placed this on my .htaccess file:

    RewriteEngine on

    RewriteRule ^home/language/(.*) home.php?language=$1
    RewriteRule ^home/language/(.*)/ home.php?language=$1
    RewriteRule ^home home.php
    RewriteRule ^home/ home.php
    Well. I still have a problem now but it is related to the fact that two flash objects that I have on the first page of the site, disappear when language is changed. The only exception is in ie6 because with safari and firefox3 these two objects do not show up anymore after changing the language of that first page.
    I am trying to fix this now but I do not know why this might happen.
    Thanks
     
    thosecars82, Oct 6, 2008 IP