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/?$
Related
I am writing an asp.net web application for internal automation.So, I am not thinking about SEO or user-friendly URLs. Just I want to change URLs for hide path and file name and query string. For example I want this URL "http://test.com/Admin/Create.aspx?id=345&name=pin" be shown for user something else that is not understandable like an encrypted URL "http://test.com/enc=nidfvegvbervmxvpazxczxcwefve" or show all URLs in all formats in a same way like "http://test.com/".
I read some articles about URL rewriting and URL routing. However, I think their method work reversely. I mean when user write "http://test.com/products/book", these method could assume it as "http://test.com/products.aspx?type=book" but I want that user couldn't see real URL ever.
Any idea?
I think what you might be looking for is Server.Transfer - check out:
http://msdn.microsoft.com/en-us/library/540y83hx.aspx
Just Encrypt the query string and decrypt on calling it
Something like
http://www.aspsnippets.com/Articles/Encrypt-and-Decrypt-QueryString-Parameter-Values-in-ASPNet-using-C-and-VBNet.aspx
Here is the thing:
Let's say I have a base URL like this:
www.mysite.com?my_first_param=1&my_second_param=2
But now I want to add a new parameter to my URL:
www.mysite.com?my_first_param=1&my_second_param=2&my_redirect_site=www.myothersite.com
Imagine that I am using a service where they add new tracking parameters to my URL. For example:
first_tracking=value1&second_value=value2
Since my BASE url already has a "?" the parameters are added with a "&", so my final URL would look like this:
www.mysite.com?my_first_param=1&my_second_param=2&my_redirect_site=www.myothersite.com&first_tracking=value1&second_value=value2
This is a correct URL with several parameters, but when I do the redirect to www.myothersite.com, since the parameters start with a "&", they get lost. Would it be correct to add the tracking parameters with a starting "?" ? Like this:
www.mysite.com?my_first_param=1&my_second_param=2&my_redirect_site=www.myothersite.com?first_tracking=value1&second_value=value2
If not, what would be a good approach for dealing with this? I believe is responsibility of the redirect to pass through the tracking parameters to the redirect URL.
You should URLencode each param name and value properly, so if the map of params you want is this:
my_first_param => 1
my_second_param => 2
my_redirect_site => www.myothersite.com?first_tracking=value1&second_value=value2
then you should pass this as the query string:
?my_first_param=1&my_second_param=2&my_redirect_site=www.myothersite.com%3Ffirst_tracking%3Dvalue1%26second_value%3Dvalue2
You should be using a library which does this already to build up URIs to handle this encoding for you.
No, you can't have a second question mark in a URL.
Furthermore, if you have ampersands in the redirect URL, they will be seen as separate parameters for the main URL, and not seen as connected to the redirect URL.
If you want to do a redirect like this, you need to URLEncode the whole of the redirected URL. There are standard functions in most web-facing languages to do this.
Encode the parameter, "?" would be replaced by %3F
It depends on the amount of control you have over the service adding the tracking parameters.
Can you change the url after the parameters have been added?
If you can, then you should use a url builder to add the tracking parameters to your redirect url, then url encode that url entriely, tracking parameters included.
If you are not in control and a third party modifies your url, then you will have to do this when you redirect, read the parameters in the url, take your redirect url and the tracking parameters, add the tracking parameters to the redirect url before redirect.
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.
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.)
For example:
http://stackoverflow.com/questions/698627/ms-access-properties
The number is part of the URL but is an argument to the web app as opposed to other options like:
http://www.google.com/firefox?client=firefox-a&rls=org.mozilla:en-US:official
where all the args come after the '?'. I have used the second form before and I'm only trying to learn about the first form.
I'm sure I can find what else I need once I known what that's called so I can Google it.
URL Rewriting, generally.
Edit: Here is a good introduction to URL Rewriting.
Variables passed in the form of a URL are called the Query String. In a url like:
http://examples.com?a=b&c=d&e=f
The query string is ?a=b&c=d&e=f
In the Stackoverflow example, it uses URL Rewriting, specifically with MVC Routing to make 'pretty URLs'. There are other ways to do it in other languages. Some make use of Apache's mod_rewrite (example) while others parse the requested URI. In PHP a url like
http://example.com/index.php/test/path/info
can be parsed by reading $_SERVER['PATH_INFO'] which is /text/path/info.
Generally, they are using URL Rewriting to simulate the query string however. In the Stackoverflow example:
http://stackoverflow.com/questions/698711/what-is-the-name-for-that-thing-that-lets-part-of-the-url-be-an-argument
The important parts are the questions/698711. You can change the title of the question with impunity but the other two parts you cannot.
It's usually called the 'path info'.
That's just URL mapping. It lets you use pretty URLs instead of a large query string.
I believe the StackOverflow URL works that way because it is using MVC whereas your bottom example is using standard requests.
It is indeed done by URL rewriting.
Usually, web application frameworks do this automatically if you install it correctly on your server.
Check out CakePHP as an example.
It's called a URL parameter and uses the HTTP GET method. As others mentioned, it can be rewritten using URL rewriting so that the URL is easier to read and use. Some search keywords: "SEF URLs", "Apache Rewrite", "pretty URLs".