Reputation: 23
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:
Upvotes: 0
Views: 282
Reputation: 2130
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?
Upvotes: 1