0

I've tried for ages to fix this problem that I have.

On my website I have rewriten some links with the htaccess file. The htaccess file currently looks like this:

RewriteEngine on

RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?sideID=$1  
RewriteRule ^([a-zA-Z0-9_!-]+)/([a-zA-Z0-9_!-]+)/([a-zA-Z0-9_!-]+)$ index.php?sideID=$1&id=$2&title=$3  

RewriteCond %{HTTP_HOST} ^www\.mypage\.no$
RewriteRule ^/?$ "http\:\/\/mypage\.no\/" [R=301,L]

The first rule rewrites from:

http://mypage.com/index.php?sideID=home

To this:

http://mypage.com/home

The first rule rewrites from:

http://mypage.com/index.php?sideID=b&id=12&title=a-great-blog-post

To this:

http://mypage.com/b/12/a-great-blog-post

Soo they do what I want too when it comes to rewriting I guess. BUT, the problem is that if im now navigated to any blog post on the site and then tryies to navigate back to whatever other link lets say http://mypage.com/home it will add http://mypage.com/b/12/home instead. That can of course be fixed easily by just using absolute URL's in the navigation. But when I try to make a XML Sitemap, the bot will index every page for each blog ID like so: http://mypage.com/b/12/home, http://mypage.com/b/13/home, http://mypage.com/b/14/home and so on for each blog ID and pagename.

Is there a way to make sure the RewriteRule's apply seperatly or set a condition for them or something like that?? I am a bit noob in this area.

I beg you, please help me! :)

Knut Pedersen
  • 205
  • 1
  • 3
  • 10
  • The rewrite rules don't create the /b/12/home URLs, they just make them work (I find it more accurate to say that RewriteRules make pretty URLs into ugly ones, not vice versa). Whatever is generating your HTML, and your sitemap.xml, needs fixing to output the right links. – IMSoP Jun 14 '14 at 08:18
  • Yeh I guess that is a more fair description. Soo you don't think I need to redo my htaccess file? For the sitemap I simply use http://www.xml-sitemaps.com/ are you suggesting I just remove the unwanted links from it? Thanks – Knut Pedersen Jun 14 '14 at 08:23
  • If a crawler is picking up those URLs, then there must be links to them in your website somewhere. Probably you've used href="home" when you should have used href="/home" – IMSoP Jun 14 '14 at 08:38
  • Yeh I tought about that as well, but I use absolute links all over now. But the crawler picks up this Current page: b/23/home, Current page: b/23/anotherpage, and it does that for every single blog like b/22/home, b/22/anotherpage. So I get like 500 links.. And if I remove the 2nd ReWrite rule, I do not get that problem. Hmm – Knut Pedersen Jun 14 '14 at 08:45
  • 1
    I cane think of any way that rewrite rule could change the crawler's behaviour, except that the URLs will show up as broken links without it. I still think there must be links somewhere for it to think those pages exist. – IMSoP Jun 14 '14 at 08:49
  • Okey, I will look closly trough my pages again. Thank you for your help IMSoP! Really appriciated it ;) – Knut Pedersen Jun 14 '14 at 08:56

0 Answers0