.htaccess rewrite url with string URI is number - wordpress

I have a website which was built with wordpress CMS. I want to change it to another theme with custom post type.
it's current url looks like:
mysite.com/1234 - links for posts - 1234 is id of the post
mysite.com/topic/cate-name - is link for categories
mysite.com/tag/tag-name - link for tags
now when i change to new theme and convert all post type, categories, tags, it causes some change likes:
mysite.com//video/1234
mysite.com/cate-vid/cat-name
mysite.com/tag-vid/tag-name
Please help me to rewrite my url with .htaccess for both apache and nginx serivce.
Thank you very much!

Related

Change a specific url to other url in wordpress using function or htaccess

Hi i have a woocommerce product and its url is http://localhost/project/product/my-product/
For this specific url i want to change the url in to
http://localhost/project/my-product/ .
Or some one take http://localhost/project/my-product/ he need to see http://localhost/project/product/my-product/ content without changing .
Is that possible using htaccess or any othe function
you can hook up into redirect rules, here is an article for that https://rudrastyh.com/wordpress/change-specific-urls.html

rewrite rule my urls in wordpress

i search a lot in the web and read many tuts and references but could not solve my problem! here is my problem: in my wordpress site i have some urls like this:
localhost/mysite/articles/?arc=8892
i have this url because in my php code i validate that article:
<?php
$article = wp_getpost($_GET['arc']); //arc = 8892
if($article->post_type == 'article')
//process article....
which 8892 is id of a post with article custom post type! also i have a plugin names custom post type permalink which set this style for this post type.
what i wanna do is rewrite below url to current urls:
localhost/mysite/article/8892
without any change in my php code.
in my htaccess code i have this but does not work:
RewriteRule ^articles/?([0-9]+)/?$ /articles/?arc=$1 [NC]
You don't have to write .htaccess manually, wordpress does it for you.
Just go to http://path/to/your/blog/wp-admin/options-permalink.php in yout browser and use one of the predefined url strucutres or write a custom one yourself.

web.com/post/post-title redirects to web.com/post-title

I'm having a complain of the SEO guy because a post url is not like this
web.com/blog/post-title
But like this
web.com/post-title
And even web.com/blog/post-title redirects to web.com/post-title
How could I restore normal behavior? it looks like they are being treated as page but they work as posts in web.com/blog
Go to Settings -> Permalink
Choose the Custom structure and fill the value with /blog/%postname%/
Need to update the htaccess inorder to get the old path works OR you can set the permalink is to /blog/%postname%/ like this
Please refer this link:
https://wordpress.stackexchange.com/questions/19238/how-do-i-add-blog-as-a-prefix-to-permalink-structure-for-blog-posts-tag-pages

WP Rewrite - Add post ID to URL

I have a custom post type (job) in my WordPress theme.
Posts of this type are inserted by users themselves, but if two or more jobs are inserted with the same title, the slug will be:
www.mydomain.com/job/title-choosen-by-user
www.mydomain.com/job/title-choosen-by-user-2
www.mydomain.com/job/title-choosen-by-user-3
...
Is it possible to keep the same slug and add the post ID in the URL using any rewrite? The result would be:
www.mydomain.com/job/100/title-choosen-by-user
www.mydomain.com/job/101/title-choosen-by-user
www.mydomain.com/job/102/title-choosen-by-user
...
Any help would be appreciated.
Thank you
Perhaps try changing your permalink structure in Settings > Permalinks under the WP admin dashboard.
Try:
/%post_id%/%postname%/
Ok I found a small but working tutorial for custom permalinks structure
http://shibashake.com/wordpress-theme/custom-post-type-permalinks-part-2

Wordpress of the post url redirect?

I have set the Permalinks to custom /%postname%/ . eg: a post id is 2, its url is
`mysite.com/test.`
i want to when the user access mysite.com/?p=2 it redirect to mysite.com/test
how do i do? or is there a pludgin to get that thank u.
You don't need any plugin for that since it is the default behavior, except if you are using a very old version of worpdress.
a little bit of googling:
http://yoast.com/wordpress/permalink-redirect/
Quote from the page:
That way, a URL like this:
http://www.example.com/page1/?q=ek
Will be automatically redirected to:
http://www.example.com/page1/

Resources