site url change by htaccess - wordpress

this is my project site http://readysolution.info/usjobs/test-category/?cpid=2&c_id=acc/
i just needed show url by http://readysolution.info/usjobs/XXXX/YYYY/VVVVV instead of this
test-category/?cpid=2&c_id=acc/
this is possible by .htaccess that my site url will be show by this new format . whetver will be display after /usjobs , it will be replace another word
example : 1) if it have /usjobs/test-category/?cpid=2&c_id=acc/ , then it will be usjobs/XXXX/YYYY/VVVVV
2) 1) if it have /usjobs/test-category/?cpid=2 , then it will be usjobs/DDDD/KKKKK
please helpl me !!!!

You can use an htaccess Rewrite to "translate" a requesting URI into a WP URI. For example:
Request in the browser: mysite.com/seg_1/wp_post_slug/seg_2
With a Rewrite you can ask for mysite/com/wp_post_slug and you'll be fine.
Please note:
1) The above is pseudo code for reference purposes and might not be accurate.
2) Somewhere in the requesting RI you're going to have to have something that can be used to identify the page / post you actually want requested. For example you can't have a request of mysite.com/xxx/yyy/zzz and then somehow have a rewrite serve you mysite.com/bbb. The bbb has to be in the request so you can use the rewrite to parse it out. (Note: Actually, tere probably is a work around for this but then you're going to have to maintain some sort of reference / conversion table.)

Related

Regex for fixing URL patterns

I have the following url structure:
http://www.xyxyxyxyx.com/ShowProduct.aspx?ID=334
http://www.xyxyxyxyx.com/ShowProduct.aspx?ID=1094
and so on..
Recently I used IIS rewrite to rewrite this structure as
http://www.xyxyxyxyx.com/productcategory/334/my-product-url
http://www.xyxyxyxyx.com/productcategory/1094/some-other-product-url
and so on..
This works fine.
I want to create another rule so that if an invalid url requests comes with the following structure:
http://www.xyxyxyxyx.com/productcategory/ShowProduct.aspx?ID=334
the 'productcategory' part should be removed from the url and the url should look like
http://www.xyxyxyxyx.com/ShowProduct.aspx?ID=334
How do I write this rule?
It may vary depending on what you are using to apply the regex, but here's a basic one:
's|productcatgory/||'
If you want to make sure it also only does this when the xyxyxyxyx url is present, this should work:
's|^http://www\.xyxyxyxyx\.com/productcategory/|http://www\.xyxyxyxyx\.com/|'
Edit: Ah, so if productcategory could be any category, then you'll need to match around it, like so:
's|^http://www\.xyxyxyxyx\.com/.*/ShowProduct|http://www\.xyxyxyxyx\.com/ShowProduct|'

How to remove the "?" character from g-wan URIs

I have checked cache.c <- totally clueless what it is doing or how to have pretty permalinks to servlet calls.
Update: OK, I know what the above does, but the problem is you have to call the above script first before you can access it as permalink. Is there any way I can access permalinks without using "?" at all (in the first place)?
I have also checked on this link: Anatomy of G-WAN URI servlets
I would like to have http://example.com:8080/servlet/arg1/arg2, without "?", and would like the above link to reference "servlet" to servlet.c.
Basically, like this pretty URL for this question
https://stackoverflow.com/questions/27084626/how-to-remove-in-g-wan-url-completely
See...no "?" within the URL.
Is this possible?
I have also checked
u8 *query_char = (u8*)get_env(argv, QUERY_CHAR);
*query_char = '!'; // use "/!hello.c" instead of "/?hello.c"
I know I can't do
*query_char = '';
you can re-write url with handler there is a simple rewrite example

Rewrite Rule Config... Is this possible?

So I have a set of pages like so:
domain.com/product/?_d=1
domain.com/product/?_d=2
domain.com/product/?_d=3
I have set up a rewrite map for cleaner URLs like so
domain.com/shoes
domain.com/pants
domain.com/gloves
So now I have nice URLs for people. But what I also want to do is start forwarding the existing URLs to the newer URLs. So for anyone who goes to:
domain.com/product/?_d=1
I want them to be forwarded or rewrite the URL to:
domain.com/shoes
I tried adding in another map where I have the following:
Original: domain.com/product/?_d=1
New Value: domain.com/shoes
And I got a 404. I guess I understand why because the other map won't apply since I am using the first map. But how can I set up a map for the old URLs? Or can I? I know if my query string value was like _d=shoes I could just do a rewrite rule, but it's not like that. I guess I could change my page to be that way, but was just looking for another way.
I ended up creating a rewrite rule that looked for the pattern to the old URLs and forwarded them to the new URL. Then in my Server side code I just did a check for those legacy variables and redirected with a 301 accordingly.

301 Redirect with Regular Expressions

Couldn't find an answer to this and thought it might be a quick answer.
My company, a local news site, is working on migrating to WordPress from a proprietary CMS. Part of the challenge is we are restructuring URLs. I will be utilizing 301 redirects but my issue is as follows:
Example Page name: Story Name: is "this"
Example Old CMS Page URL: /story-name--is--this-/
New CMS Page URL: /news/2012/09/12/story-name-is-this/
The old CMS turned special characters and spaces into hyphens. WordPress will be configured to instead ignore special characters and simply turn spaces into hyphens. Additionally, the old CMS did not include the date in the URL, and I'm not sure the best route to take regarding adding the date.
Thanks!
You're either going to have to write a script that takes all of your old links, does a lookup in your database to transform it into the new link, and redirect the browser to the new link. Or you'll have to enumerate the entire mapping of old links -> new links and create a 301 redirect for each of them (in either your vhost/server config or in an htaccess file):
Redirect 301 /story-name--is--this-/ /news/2012/09/12/story-name-is-this/
It's not clear what is your real question? I am also not sure what Regular expressions have to do with the problem.
There is no information about what your old CMS is capable of, assuming that you can intercept the calls to old articles when they are accessed via the browser, but before they are rendered you can form and send the redirect back to the browser dynamically generating the url using the programming mechanisms available in your proprietary CMS.
Again, assuming you have access to Java:
A. When generating the redirect URL you can access the article's date and form the
2012/09/12 from the date, you can use SimpleDateFormatter to format Dates into a string representation like YYYY/MM/DD.
B. You can use similar approach with the titles and replace the list of special characters in the title string with empty spaces. For example Apache StringUtils library can let you specify a set of characters to look for and if any are found they will be replaced with the target character.
C. You concatenate the output of A and B to create the target redirect URL and send it back to the browser instead of the article itself.

IIS7 URL Rewrite Patterns Query Template after QueryString

I am creating a Friendly URL Patterns in IIS Rewrite
my normal URL would look like this
http://localhost/orgprofile/financial.aspx?name=Test
and initially I picked from the options available in IIS
the friendly URL with
http://localhost/orgprofile/financial/test
With Pattern
^orgprofile/financial/([^/]+)/?$
Now I only want to change the friendly URL to
http://localhost/test/financial
So yes the querystring first then append financial
I can get this friendly URL to work
http://localhost/financial/test
^financial/([^/]+)/?$
But cant get this to work
http://localhost/test/financial
i.e something like
([^/]+)/?$/^financial
$ means the end of the query string - you need to leave that at the end.
Try:
^([^/]+)/financial/?$

Resources