Website URL rework / reformat to user-friendly - php

I need some advice on where and how I should start this project. The current site is running classic ASP but uses .php extensions in the file system (don't ask - previous freelance).
Current URL structure has sub folders that contains display pages that renders the page
team/team_detail.php?teamID=3&Source=Title&Title=Partner
Only the teamID part actually does anything and query the data in a team table.
I was thinking of using the IIS url rule and add user friendly rule for each matching URL patterns. I was planning to change all website code to use new structure:
url team/team_detail/3/bob-titans
Old url formant that will still work team/team_detail.php?teamID=3&name=bob-titans
Would this complete site wide URL change be the most effective way to do this or would there be another more effective method?

If your main objective is to change the URL structure of the site (and clean up stuff like the unused "Source" and "Title" parameters while you're at it), then the approach is sound:
Modify the site code to use the new URL strategy (for example, with ASP.NET Routing).
Use the IIS URL Rewrite Module to create rules to properly redirect or rewrite the old-style requests to the new format. If this is a public site, and you are concerned about SEO, you should consider making these redirects use the 301 response type to tell search engines the resources under the old URLs have moved permanently to the new URLs.
It's a nice approach because you can focus on updating your code for the new structure, and let IIS take care of any users still referencing the old URL formats.

Related

How to redirect old URL from a custom PHP website to new WordPress URL?

I have a client that needs to rebuild their site from custom PHP website to WordPress instalation. The client run a local news site and has tons of news articles in it. Approximately more than 3000 URLs.
The old URL structure look like this:
http://localnewssite.com/news-85720-trump-is-the-king
I need to move them to the new URL like this:
https://localnewssite.com/category-name/article-title
I had two problems in here.
The first one is the old article URL has no category for each of the article, so they just use single "news" category for all of their article URLs and the article's ID number in the database despite their site has 12 news category in it.
The second is I counted approximately more than 3000 articles with that old URL style that I need to move.
I was only given the MySQL database file as the old developer refused to give any access to my clients for their own server.
My client intended to move the site to a new VPS account, so this could be tricky.
Is there any way to use regex or any HTACCESS to automatically and easily redirect 301 all of the old URLs to the new one?
I can't manually move each of the article and reconfigured all of the URL for SEO using Yoast plugin because it would take a lot of time.
Thank you.
You can either use this plugin Redirection, Or write code in htaccess to 301 redirect old urls to new urls.
Redirect 301 /old-url https://yourdomain.com/new-url

Codeigniter URL routing - SEO concerns

We have a good old website where all the pages are static and we are updating them by editing the HTML files. Every redesign is a lot of work for us since we copy and paste all the texts from old to new design. If we need to change any single thing about design, we need to change it in all other pages one by one.
Now we have developed a site by using Codeigniter and want to replace that static pages with database-driven pages. We will put all the content to the database so we will have just one product page and retrieve any product info according to the query string.
The problem is we don't want to change the old urls with the new Codeigniter urls because of search engine ranking concerns.
URLs in the old website are like these:
example.com/code1001.php
example.com/code1002.php
example.com/very-good-product-1003.php
example.com/brand-new-product.php
example.com/product-listing.php
The Codeigniter URLS in the new website are like these:
example.com/products/details/code1001
example.com/products/details/code1002
example.com/products/details/code1003
example.com/products/listing
After a quick research, I thought that I can use CI's routes.php to display database-driven pages when user/google hit to the old URL.
I can use the below code to do that.
$route['code1001.php'] = "products/details/code1001";
$route['example.com/very-good-product-1003.php'] = "products/details/code1003";
$route['brand-new-product.php'] = "products/details/1004";
$route['product-listing.php'] = "products/listing";
I don't want this to be a 301 or 302 redirect, I just want to replace the static pages with the database driven pages and leave the urls same.
Do you think that this will have a negative effect on SEO? Is Google able to notice this routing?
Best Way For dynamic routing is
$route['confirm_registration/(:any)']= "login/confirm_registration/$1";
For redirect you can use .htaccess

Redirect url for public page in wordpress?

I am working on this site developed in Wordpress 3.3.1. My client wanted me to develop a public page. This page will be a simple php page. It will reside in wordpress directory but will not be a part of CMS itself. The issue here is that I want a url redirection for this page. My client wants to send a link in email to members of the website, so he wants to keep the url clean.
This is the format of current url that he wants to send to the members:
'http://www.example.com/shop/"url_encoded_category_name"/product/"product_id"'
And I want to redirect it to:
'http://www.example.com/template-public-home?productId="product_id"'
I was rewriting the url for now. But as you can see in the first url format that "url_encoded_category_name" and "product_id" are variables and therefor rewriting would mean that I am trying to rewrite different urls to same url(only query string changes). I want to change it to redirection because as I understand this approach of rewriting multiple urls to the same url is penalized by most of the search engines.
For rewriting I edited the .htaccess file.
What I wanted to ask is that considering that I have a publicly accessible page within wordpress directory:
what is the most suitable way to redirect my url?
In my case what is a better Code? 301 or 302?
Thanks for any assistance you can provide or direct me to a source where I could learn about it.
First of all, if your client just wants to use the generated URL in emails to members, no search engine will ever know. However, if there is a chance that they leak you might indeed end up with duplicate content. Redirection then is the correct approach.
You can redirect just as you rewrite by using the [R] flag in your rule (usually in conjunction with L as [R,L] so that the rules below that match are not executed.
From the point of view of a search engine (and a user as well), these are permanent redirects - you will never ever use the URL in the email as a primary URL (or will you?). That means you should use R=301.
Take a look at the documentation to learn about the flags, test your rewrite rules online here and check https://stackoverflow.com/questions/1426056/good-htaccess-mod-rewrite-url-rewriting-tutorial for some hands-on material.

301 versus inline rewrites

I'm in the process of adding 'pretty' URLs to an existing CMS, the menu is auto generated and the new 'pretty' URLs are to be handled independently as a seperate module. The auto-generated menu allways has URLs that look like this index.php?menu_id=n which ofcourse we would like to see as eg. /news or /products
I'm currently at the point where I have to decide if I'm going to rewrite all output of the current system or simply put in a hook where I redirect to the 'pretty' URL.
To put it differently, should i connect to the database, fetch all 'pretty' URLs, run through the existing output from WYSIWYG's, news modules, forums etc. and do some str_replace or other string manipulation (which I think would be a rather tedious and boring process), or should I simply hook in and throw a 301 redirecting index.php?menu_id=3 to /news will Google (or other search engines) penalize me for having 301's in the menus?
301 is a permanent redirect, and search engines understand them. They don't penalize you for a 301.
My recommendation - a combination of both. For pages in your control, modify the urls. For ones beyond your control (third party blogs, other websites etc) and for your own pages that are difficult, 301s should be fine.
There is a performance aspect to 301s as well, so avoid them when you can. But if you don't have a choice, its okay.
A 301 redirect is competely the correct behaviour in this instance because the resource has 'moved', and Google should not penalise you at all.
I would recommend attempting to replace as many as you can using a simple clean-up process. I faced the same issue and solved the problem by...
1) Detecting requests to the old URL and issuing a 301 redirect (useful especially for external links to the page)
2) Any auto-generated URLs such as the menu were updated as the code changed to generate the friendly URL
3) For WYSIWYG I performed a clean up once across all of the content to replace old URLs with the new friendly URLs, which meant less redirects being sent to the client and no "old" style URLs being displayed in status bars.
of course you have to rewrite output system.
or there will be no point in URL rewriting at all

Migrating an existing PHP site to use URL re-writing (Pretty URL's)

I currently have a community site that I run that is made up of 15 or so php pages. It is not currently very dynamic, only using php for includes/templates.
Currently no content is generated via a query string. The pages do not follow a standard naming convention and there are many inbound links.
I am looking to expand the site (and start using query strings to build pages) but before I do this I want to change over to use pretty url’s. With this in mind I have a few questions though.
1) Is it best to point all requests to a url rewriting page catch any request to .php pages first and pass them through to keep existing links then a giant case statement for each of the 15 pages finally the rewrite the url's of new pages as these will follow a set format?
2) How can I prevent duplicates in google after I have updated my sitemap.xml or will it remove the old pages?
Thanks
1) I'd redirect using apache's URL rewrite, and leave that static. It'll avoid the mess of having those 15 files you already have in your site.
I hope I have not misunderstood your question and this helps.
2) Edit robots.txt in the root of your website to tell google (and most others) what it should index, and what it shouldn't:
Google's info on the subject: http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=40360
Wikipedia: http://en.wikipedia.org/wiki/Robots_exclusion_standard
More info: http://www.robotstxt.org/
You should use a 301 permanent redirect from the old pages to the new URLs. This will redirect users that follow links from the old to the new and Google will pass the PageRank you have accumulated on the old pages to the new one. You might also look at using Googles new canonical tag on the old pages to ensure they transfer authority to the new page.
http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html
In .htaccess, you want a bunch of
redirect 301 /old/old.htm http://www.you.com/new.htm
Regardless how its implemented, make sure any redirects use HTTP status 301, not the default (in may systems) of 302.
302 = Moved
301 = Moved permanently.
Using 301 helps google replace the old with the new URL, and should help pagerank etc carry over as well.

Categories