Wordpress permalink / previous URL issue - wordpress

My work has recently converted their website to run on Wordpress. The old website was made in ASP. Our marketing department have advertised a specific URL for an event, but now that URL has changed.
The old URL is: /who-are-you/stem-intro.aspx
The new URL is: /stem2014/
Can I used my htaccess file to make the first URL go to the second url without an .aspx file existing?
Thank you for your help.

Yes you can use this rule on top of your WP .htaccess (just below RewriteEngine line):
RewriteRule ^who-are-you/stem-intro\.aspx$ /stem2014/ [L,NC,R=301]

Can be performed easily with a 301 redirect in .htacess, especially if this is a one off thing
Redirect 301 /who-are-you/stem-intro.aspx http://www.YOURSITE.com/stem2014/

Related

Redirect URL without changing file served to user

I need to change the url on a website from /blog/contact to just /contact
But I still need application to serve the content as if the user is still accessing the original URL.
Is it possible within .htaccess to change the URL without changing any of the architecture or logic of the backend? Kind of like a permanent 301 alias?
Thanks
I found the solution to this with the following rule.
RewriteRule ^blog/contact/$ /contact [L]

How to 301 redirect for tags and categories in wordpress?

Hi Please sorry if my question was simple or very basic. But please some one tell me how to fix this problem
i need to redirect all my website pages and post from old url to new one
example :
blog.mysite.com/posttitle.html
301 redirect to
mysite.com/blog/posttitle.html
Already some rule written in htaccess but it only redirects blog posts and pages.
301 redirection is made only for the blog post and pages. But not for all tags, all Categories and all author pages. the following pages are not redirecting ,
blog.mysite.com/tag/mytagname
blog.mysite.com/categories/categoriesname
blog.mysite.com/author/authorname
how to redirect this to new site
mysite.com/blog/tag/mytagname
mysite.com/blog/categories/categoriesname
mysite.com/blog/author/authorname
There are plugins that can take care of all this for you. No messing with .htaccess. All done by modifying WordPress own rewrite rules
https://wordpress.org/plugins/redirection/
https://wordpress.org/plugins/quick-pagepost-redirect-plugin/
https://wordpress.org/plugins/simple-301-redirects/
If you want to do yourself try adding this to your .htaccess
RewriteEngine on
RewriteRule ^(.*)$ http://your-site.com/blog/$1 [R=301,
This would go before the WordPress specific part of .htaccess 'begin WordPress'. That section can be overwritten by WordPress automatically.

How can I use htaccess to redirect paths with a wildcard character in wordpress

I recently changed my 92 category links and now I am getting hit with hundreds of 404 errors from Google because the old links are not found. I tried to use plugins to automatically redirect single URLS but I am noticing there are more and more coming in and doing everything on a 1 by 1 basis is not efficient.
I was hoping someone could assist me on getting my pages redirected using my htaccess file.
For Example Going to
example.com/category/old-category/
should redirect to
example.com/category/new-category/
More importantly I would like to redirect the page numbers of the old categories to the page numbers of the new categories using a wildcard. So page x of old category will redirect to page x of new category.
example.com/category/old-category/page/5/
should redirect to
example.com/category/new-category/page/5/
Thanks in advance.
You can use this generic redirect rule just below RewriteEngine line:
RewriteRule ^(category)/old-category(/.*)? /$1/new-category/$2 [L,NC,R=301]

Remove Old Permalinks?

I have a Wordpress website. I have changed my permalinks several times. All past versions of the permalinks I used are still working. If I type them into the URL bar, I am taken to the page WITHOUT the URL changing/redirecting to the new/current permalink.
Why aren't the old permalinks redirecting to the new one?
This is causing issues with Google reading duplicate content.
Example: .com/lightbulb .com/shop/lightbulb
The second URL is old, but still works when I type it in.
Shouldn't it redirect to the new one?
How can I remove old permalinks from being found by Google?.
Thanks in advance
I think the old permalinks is stored in the table postmeta with the meta_key of _wp_old_slug
If you wanted to clear all of the old slugs you could use this:
DELETE FROM wp_postmeta WHERE meta_key = '_wp_old_slug';
As you can see, Wordpress doesn't handle redirections when you change your permalinks structure. There is 2 ways to handle this, through:
The htaccess rewriting rules (manually editing the .htaccess file) depending on your new old/new permalinks structure. If .com/lightbulb is the new path and .com/shop/lightbul the old one:
Options -Indexes
Options -Multiviews
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
RedirectMatch 301 /shop/lightbulb(.*) /lightbulb$1
# or
# RewriteRule ^shop/lightbulb?(.*) http://www.domain.com/lightbulb$1 [R=301,L]
</IfModule>
But if you want to redirect old permalink structure .com/shop/ to main domain your .htaccess rules will be:
Options -Indexes
Options -Multiviews
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
RedirectMatch 301 /shop/(.*) /$1
# or
# RewriteRule ^shop/?(.*) http://www.domain.com/$1
</IfModule>
Permanent redirection is used for best SEO practices, redirecting definitively old permalinks to new ones, avoiding duplicate content, and telling search engines that your old permalinks have been moved definitively to new ones.
Redirection Wordpress free plugins (there is a lot):
Redirections plugin is the most popular and offer a easy-to-manage 301 redirections and 404 error tracking. It also offers more advanced tools to help you keep track of loose ends on your site like broken links and orphan pages.
Simple 301 redirects plugin is simple and deals with 301 redirect creation for when you’ve permanently moved content from one location to another.
Quick Page/Post Redirect plugin easily redirect pages/posts or custom post types to another page/post or external URL by specifying the redirect URL and type (301, 302, 307, meta).
Safe Redirect Manager plugin comes with an additional whitelist feature for added security…
SEO Redirection Plugin plugin offers support for generating 301, 302, and 307 redirects and also supports 404 error monitoring with easy one-click redirection…
Converting old path (urls) in database (if they still exist):
You can use Search and Replace free plugin, to easily find some old related urls or path in your database and bulk replace them by the new ones. This is a very powerful plugin, a little buggy, but working fine when you know it (but make always a backup before).
A recent reference:
A Simple Guide to Changing Your Permalinks Without Breaking Your WordPress Website
Why aren't the old permalinks redirecting to the new one?
Each time you add new permalink structure and flush rewrite rules, WordPress doesn't redirect old links to new links. Instead, WordPress will alter the old links with the new links completely.
All past versions of the permalinks I used are still working.
In WordPress, a URL doesn't map to route. It's looped through rewrite rules to find a match - a real URL which can be translated into database queries by parse_request method.
It means that if the old rewrite rules which match old links aren't removed. The old links still work.
How can I remove old permalinks from being found by Google?
Since they have been indexed by Google, I think permanent redirects is the best solution.
I assume you're using Apache, if not, please let me know.
In your case, just add following code before WordPress rules in your .htaccess file:
RewriteEngine On
RewriteRule "^shop/(.+)/?$" "http://example.com/$1" [R=301,L]

How to redirect a page in a site to another page in wordpress

I am trying to get a url to be redirected to another site.
For eg. www.abc.com/joe needs to be redirected to www.xyz.com/joe
where www.abc.com is a wordpress site.
thanks
Prady
You can do this at the web server level; WordPress isn't involved. Add to your .htaccess:
RewriteRule ^/?joe$ http://www.xyz.com/joe [R=301,L]
After the "RewriteEngine On" line that's already there because of WordPress.
You might find this answer I wrote over at SO's sister site WordPress Answers to be helpful. In short you can use PHP and a WordPress hook to do the redirection which keeps you from having to mess with .htaccess and gives you a lot more control over what happens as well:
Creating 301 Redirects for Post, Page, Category and Image URLs?
Hope this helps.
-Mike

Resources