Mod Rewrite help

by 12 replies
14
I am trying to make SEO friendly urls. Im trying to make the url news.php?readmore=5 into /oddsmaker-sportsbook-bonus

The problem I'm having is that it doesnt change the URL in the browser for news.php?readmore=5 but if i type in /oddsmaker-sportsbook-bonus it shows up the way I want. I'm trying to get a link to readmore=5 to show the other url. Any advice? Here's my code.

Code:
RewriteRule ^oddsmaker-sportsbook-bonus/?$ news.php?readmore=5 [NC,L]
#search engine optimization #mod #rewrite
  • That rewrite rule will take effect on the server. If you want to force it to change on the client as well you need the following (typed straight into the forum so untested!).

    Code:
    RewriteRule ^news.php?readmore=5$ oddsmaker-sportsbook-bonus/ [NC,R]
    Put that rule first and it'll force a 302 temporary redirect on the client if they go to news.php?readmore=5

    Then with your rule it'll convert it back internally and allow the script to figure out what to do.

    Hope that helps.

    Andy
    • [ 1 ] Thanks
    • [1] reply
    • Andy,

      Not entirely sure i follow. I put that rule first like this

      Code:
      RewriteEngine On
      RewriteCond %{THE_REQUEST} ^news.php?readmore=5$
      RewriteRule ^news.php?readmore=5$ oddsmaker-sportsbook-bonus/ [NC,R]
      RewriteRule ^oddsmaker-sportsbook-bonus/?$ news.php?readmore=5 [NC,L]
      It still isn't working.

      Thanks for the help.
      • [1] reply
  • Hm.. still not working. If i go to Sportsbook Review - Sports Wagering, Top Online Sportsbooks - News: Odds Maker Sportsbook 100% Deposit Bonus it works correctly but still at Sportsbook Review - Sports Wagering, Top Online Sportsbooks - News: Odds Maker Sportsbook 100% Deposit Bonus it shows the dynamic url. Here is the updated code i am using
    Code:
    RewriteEngine On
    RewriteRule ^news.php?readmore=5$ oddsmaker-sportsbook-bonus/ [NC,R,L]
    RewriteRule ^oddsmaker-sportsbook-bonus/?$ news.php?readmore=5 [NC,L]
    I really appreciate all the help. I've been trying to make this work for 2 days and still cannot figure it out.

    Thanks.
    • [1] reply
    • Hmm ... OK. I'll be back at my place in a couple of hours. Will figure it out and get back to you then. Feel free to prod me via PM if I haven't replied later on.

      Cheers,

      Andy
  • Thanks Andy, I really appreciate it!
  • I'm an idiot. The initial pattern will have a / in front of it so neither of these rules will ever match -

    Code:
    RewriteEngine On
    RewriteRule ^/news.php?readmore=5$ oddsmaker-sportsbook-bonus/ [NC,R,L]
    RewriteRule ^/oddsmaker-sportsbook-bonus/?$ news.php?readmore=5 [NC,L]
    Try that.

    Cheers,

    Andy
  • That still doesn't seem to do it. Now if i type in readmore=5 it still shows that URL. If I use the URL I want to work it comes up with a 404 error.
  • Oh I'm just being a bit of a failure all around today.

    You'll also need initial slashes on the replacement pattern as well -

    Code:
    RewriteEngine On
    RewriteRule ^/news.php?readmore=5$ /oddsmaker-sportsbook-bonus/ [NC,R,L]
    RewriteRule ^/oddsmaker-sportsbook-bonus/?$ /news.php?readmore=5 [NC,L]
  • Hm.. Still having the same problem.. Don't feel like a failure either I've been struggling over this for days.
  • Hmm ... OK that's odd. Now that exactly matches what I've got on my server.

    I'm not going to be much more help without your hosting details. If you're happy for me to take a look inside your server please PM your login details but I understand if you're not happy to hand that kind of info out.

    Cheers,

    Andy
  • Yeah, Andy is right, it won't help without your hosting details...

    But be carefull before handing your login id to some one. As, once I had given my details to a programmer for cerain programming and instead of resolving the issue he changed the ID for adsense... When for some days I saw zero earnings on my site, I got amazed. When checked in detail, I come to know that there were no adsense on the sites... Rather all the earnings were flowing to the programmers' ID.

Next Topics on Trending Feed

  • 14

    I am trying to make SEO friendly urls. Im trying to make the url news.php?readmore=5 into /oddsmaker-sportsbook-bonus The problem I'm having is that it doesnt change the URL in the browser for news.php?readmore=5 but if i type in /oddsmaker-sportsbook-bonus it shows up the way I want. I'm trying to get a link to readmore=5 to show the other url. Any advice? Here's my code.