Search code examples
ajax.htaccessmod-rewritesearch-engine

RewriteRule - Check if certain Term in URL exists, if not add it


I am currenctly facing some htaccess/rewriterule issues. (And I am new to this area)

Let's assume we have an url like this: http://mypage.at/very/cool

The URL is supposed to look like this (Cause I am using an AJAX-loadedContent which requires this): http://mypage.at/#ajx/very/cool

So I would like to add the part '#ajx' to every url which does not already contain it. Which means if an url does already look like: http://mypage.at/#ajx/so/pretty then there is no need for changes.

As I am not sure wheter this creates troubles with the GoogleSearchIndex, I would additionally like to know if there is a way to exclude this rule for searchbots.

Thanks for any help. Ripei


Solution

  • Hah finally after lot's of reading and testing - I got it.

    RewriteCond %{REQUEST_URI} !^#ajx
    RewriteRule . /\#ajx%{REQUEST_URI} [L,R,NE]
    

    This Code works for me... don' ask me why this one is working, to be honest I do not have a clue! But well I am fine with the fact, that it IS working :)