I've a whole website built upon a hyperlink plan of query strings (i.e. ?page=about or ?page=individual&i=johndoe). Obviously, looking back we've made the decision to choose another (beautified) plan to be able to become more Search engine optimization friendly (i.e. /about/ or /individual/johndoe/).

It is possible to way to do this change using mod_rewrite with an Apache .htaccess file without needing to change all of the links sitewide? For example, should you click a hyperlink to ?page=about this would permanently redirect you to definitely /about/.

The code I've attempted will effectively display /about/ as ?page=about, however, there's no redirect involved. And to tell the truth, I have never done any operate in mod_rewrite (and it is a little intimidating), and so i feel I am pointed in the wrong direction. Nevertheless, here's the code I have been dealing with to date:

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

RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)$  /$1/$2/ [R]
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/$ /index.php?page=$1&i=$2
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/$ /index.php?page=$1&id=$2
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/$ /index.php?page=$1&bctid=$2
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/$ /index.php?page=$1&bclid=$2

Any ideas? I greatly appreciate any help.

First... The rewrite is only going to affect spinning demands. Consequently your changes indexed by the questions you have will allow a webpage to become utilized in 2 ways:


This means that unless of course you are making changes throughout your website you won't be making a change since everybody is pointing towards the wrong URL.

I believe rather you need to use mod_redirect, to redirect the consumer towards the more recent created URL. I believe after that you can obtain that new url get planned to the version your website really needs. In my opinion this works, and does not result in a loop.

That being stated i believe there's some Search engine optimization ding since there's a redirect on all pages, with no one really indicates the better Web addresses directly. That may not provide you with the results you would like. Another option is to make use of individuals regex that you simply provide, and really result in the real code change in most your sights. That could be easy or hard for the way you're making your links.

Best of luck.


I just read the questions you have as you would like a number of different things:

  1. you won't want to change anything huge in the manner your website works however, you want nice Web addresses (possibly you're utilizing a framework forces pages to become known as such as this). What this means is you need to support both ugly and nice web addresses, and that means you need mod_rewrite to ensure that both versions work.
  2. Your ultimate goal would be to make smarter web addresses for search engines like google. This means that you need to "encourage" customers who make use of the ugly Web addresses to rather make use of the nice Web addresses. For the reason that situation you need to most likely cleanup your old web addresses in your site. Otherwise google continues to crawl the ugly web addresses (since individuals would be the only ones it saw).
  3. You cannot cleanup other bands Web addresses which means you should most likely mod_redirect their links to ugly web addresses for your nice ones. This way google will discover the excellent web addresses nicely. (this is actually the part i am unsure of. Will the mod_redirect and mod_rewrite result in a loop? I believe not, but when it will then only #1 and #2 could be possible, and you'd simply need to accept other individuals sites pointing for your ugly web addresses