0

Good day. At the moment I am busy remodeling the website. Can't solve several problems.

1.I need to change the url structure - for example a link to «somepage» like:

site.com/index.php?page=somepage

now will look like:

site.com/someCategory/somepage

As I understand in order not to lose page rank of «somepage» I need to do a 301 redirect. As I understand it will look like this:

Redirect 301 site.com/index.php?page=somepage site.com/someCategory/somepage

If more than one page (approximately 400) then it will look like this:

Redirect 301 site.com/index.php?page=somepage site.com/someCategory/somepage
Redirect 301 site.com/index.php?page=somepage1 site.com/someCategory/somepage1
Redirect 301 site.com/index.php?page=somepage2 site.com/someCategory/somepage2

Redirect 301 site.com/index.php?page=somepageN site.com/someCategory/somepageN

2.I need to make a redirect from www to non-www. It will look like this:

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

3.Also, currently my .htaccess file has rules to create pretty URLs:

DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)/(.+)/?$ index.php?category=$1&page=$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)/?$ index.php?category=$1

The questions are:

  • How to combine them all? In what order should I arrange it all?
  • Whether redirection to work normally in the presence of about 400 301redirects?
  • Maybe you can point me to my mistakes?
fntms
  • 23
  • 2

1 Answers1

1
RewriteEngine On

# www to non-www
RewriteCond %{HTTP_HOST}  ^www\. [NC]
RewriteRule ^(.*)$  http://domain.com/$1  [R=301,L]

# SEO format to dynamic format (200, not 301)
RewriteRule  ^someCategory/([^/]+)/?$  /index.php?page=$1 [QSA]
# 'someCategory' is fixed text

Is someCategory going to vary? Would it be useful to make it another Query String variable?

How does #3 differ from #1? You don't do a 301 mapping SEO format to internal dynamic format. Is #3 more SEO-to-dynamic? How do you tell apart #1 and #3?

Phil Perry
  • 2,126
  • 14
  • 18
  • There are already existing website. All references to it from the outside at the moment (e.g. search engines) are: `site.com/index.php?page=somepage` (the only variable - page) For example, the user clicks the old link `site.com/index.php?page=page1` and it in turn redirects (#1) him to `site.com/someCategory/page1` (somecategory and somepage - variables) and then #3 begin to work. #3 is responsible for converting `/someCategory/page1` in the clear for php `index.php?category=someCategory&page=page1`. Maybe it all together impossible to implement? Hope I explained clearly – fntms Mar 19 '14 at 14:43