Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Feb 2012
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How could I make links friendly?

    Hello! I want to make the links friendly, but I have some problems. I want to change www.mysite.com/index.php?page=motos in www.mysite.com/motos.html
    In .htacces I have written:
    Code:
    Options +FollowSymlinks
    
    RewriteEngine on
     
    RewriteRule ^([a-z0-9_]+).html$ index.php?page=$1
    but it's not enough.
    I think that I make some changes in my php file, too. In my php file I have:
    Code:
    href="index.php?page='.$name.'"
    where $name could be motos or vehicles or...
    How could I change href in my php file ? With preg_replace? Thank you very much!
    Last edited by milanello72; 02-29-2012 at 10:49 AM. Reason: How could I obtain friendly links?

  2. #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    15,060
    Thanks
    165
    Thanked 2,250 Times in 2,237 Posts
    PHP Code:
    href="'.$name.'.html" 
    ?

  3. #3
    New Coder
    Join Date
    Feb 2012
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for your message, I tried, but not working...

  4. #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    15,060
    Thanks
    165
    Thanked 2,250 Times in 2,237 Posts
    I tried, but not working...
    What's not working? The PHP side/ rewrite side ?

  5. #5
    New Coder
    Join Date
    Feb 2012
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think that php side not working... It's for the first time when I try to work with htaccess and I haven't experience.

  6. #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    15,060
    Thanks
    165
    Thanked 2,250 Times in 2,237 Posts
    I think that php side not working...
    Make use of the "view source" option of your browser to check the output of that code.


 

Posting Permissions

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