How to guide through .htaccess



  • How do you get a direction through...htaccess? I have a code that guides. http://site/andreyhttp://site/profile.php?user_url=andrey

    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?user_url=$1
    RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?user_url=$1
    

    And how to guide. http://site/andreyhttp://site/profile.php?user_url=andrey and plus http://site/andrey?article=123http://site/article.php?article=123



  • For starters, stop team performance in the first rules by adding [L] at the end of the rules.

    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?user_url=$1 [L]
    RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?user_url=$1 [L]
    

    update

    Instead of two identical rules, it is easier to write one.

    RewriteRule ^([a-zA-Z0-9_-]+)/?$ profile.php?user_url=$1 [L]
    

    update

    And it's more right to send an address without an eye at the end to an address with a surveillance, automatically.

    RewriteRule ^([a-zA-Z0-9_-]+)$ /$1/ [R=301,L]
    RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?user_url=$1 [L]
    

    In doing so, the search system will forget to duplicate the page http://site/andrey And it will always be. http://site/andrey/

    update

    I think I need something like that. https://stackoverflow.com/questions/20383669/htaccess-rewriterule-page-with-query-string I don't really know how to write this technique, because it's not really kosher, it's easier to change the php url to normal CPU, and then it's human.

    update

    It's working for the forehead, but we still need to get to the variable value of 123.

    RewriteCond %{QUERY_STRING} ^article=123$
    RewriteRule ^andrey$ /article.php?article=123 [R=301,L]
    

    update

    Done.

    RewriteCond %{QUERY_STRING} ^article=([0-9]+)$
    RewriteRule ^andrey$ /article.php?article=%0 [R=301,L]
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2