Source Urls having '#' in them (anchor links) are not redirecting - tomcat7

I currently have a redirect filter working on an old site with 100+ html pages (static site). However, the remaining API docs (200+ pages) which all have a "#" in them are not redirecting. The original site was implemented as an SPA and hence had anchor links for all API docs; the target site have clean urls.
Snippet of UrlRedirectFilter
<rule>
<name>Delete Transactions</name>
<from>^/api/#create-transaction-deletion$</from>
<to last="true" type="redirect">https://baseurl/apis/Transaction/deleteTransactions</to>
<rule>
<name>Payment Charge</name>
<from>^/api/#paymentcharge$</from>
<to last="true" type="redirect">https://baseurl/apis/Payment%20Method/PaymentMethodCharge/</to>
Is there a hidden rule in url tuckey filter that discards anchor links? Is there a regex I need to be aware of? If none of the regex patterns work on the filter, what's the best way to move forward by extending urlrewriteFilter? Thanks!

Related

outboundRule for dynamically generated content using the IIS Rewrite module

I am trying to write the outbound rules for URLs using the IIS Rewrite module. It is working fine for the static URLs, however, the outbound rule is not applying on the dynamically generaged URLs using the script. In some places in the application, the anchor tags with href () are generating using the jQuery script. The outbound rules are not applying on these type of URLs.
I am using the below pre condition to include the script files, still not working.
<preCondition name="ResponseIsTextAnything">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/(.+)" />
</preCondition>
Appreciate your expertise suggestions here. Thank you.

URL Forwarding based on request parameters

I am using UrlRewriteFilter from http://www.tuckey.org/urlrewrite/. Mainly I am trying to get the following URL http://domain/application/?param=value to redirect to http://domain/application/?another_param=another_value (simply replacing the request param).
Below are my rule configuration that dosen't seem to work
<rule>
<from>^(.*?param=value)$</from>
<to type="forward">%{context-path}?another_param=another value</to>
</rule>
I have tried several other variations but that didn't seem to work either. any light shed on this issue would be much appreciated
I have been able to resolve the issue using the rule below
<rule>
<name>Selective redirect example redirect</name>
<condition type="parameter" name="param" operator="equal">value</condition>
<to type="forward">?another_param=another_value</to>
</rule>
The key to the answer here is using the conditions rather than depending on the rule to capture the request, in my case I needed only to apply the rule when a certain param value is met. The second part of the answer is removing the <from> tag, and hence all the requests that fulfill the condition will be redirected to the same source page.
Finally, below are the links that were most useful in my search for the answer:
URLRewriteFilter Examples page
The Developer's Tidbits: Tuckey URLRewrite How-To
StackOverflow post: URL Rewrite Filter not working with query parameters containing special characters

google ajax crawling rewrite

I have a site with some ajax content.
links to ajax content pages are as follows
!/category/id/ident/name/
apache rewrite
RewriteRule ^category/([^/]+)/([^/]+)/([^/]+)/$ /somephp.php?cat_id=$1&ident=$2 [L]
redirects these links to /somephp.php?cat_id=id&ident=ident
I'm assuming google makes a request to /_escaped_fragment_?category/id/ident/name/
that is to say, no key=value pairs in new google request.
Then I assume I can rewrite this to /googlecontent.php?cat_id=id
so delivering googles html snapshot.
I've not been able to locate any information regarding _escaped_fragment_?whatever not having key=value pairs, is this ok with google?

SEO URL redirect: www - http://www - etc

I am creating a CodeIgniter site. I have an SEO problem to address. The following URLs all point to the same page, although search engines see them all as different urls:
www.yahoo.com
http://www.yahoo.com
http://www.yahoo.com/
Does CodeIgniter have a function that can automatically redirect pages to a single URL?
if not, has anyone written a function that can create a unifying URL for the redirect?
Currently I am redirecting all pages to:
"http://-----.com/" . uri_string();
Use canonical URLs. Basically you tell the search engines that when they pull up that page by any of those URLs that the one you specify as the canonical URL is the one to be considered the "main" URL and shown in their index. The others are then not considered duplicates.
<link rel="canonical" href="http://www.yahoo.com/" />

Tricky set of redirections needed for URL Rewrite

If I have a website, say my http://www.website.com, what is the best way to redirect traffic to a default.aspx page but not have that shown in the url?
So if the user goes to http://mywebsite.com they get redirected to http://mywebsite.com/default.aspx?lid=1234 but that is displayed as:
http://mywebsite.com?lid=1234
When my site goes live (obviously the site is not http://mywebsite.com, but the main url is not relevant) I want to be able to give them the url above.
At the moment its a bit tricky, when we gave them the URL, it didnt have a parameter lid, but now the system requires it.
I changed http://mywebsite.com to http://mywebsite.com/default.aspx?lid1234 by setting index.html as a higher default page and having the code http-equiv="refresh" content="0;URL=default.aspx?lid=1234"
That worked.
If I then apply the standard rewrite rule for removing default.aspx as shown here: http://kitsula.com/Article/URL-Rewriter-Remove-default.aspx-from-the-URL
It almost works. The redirect goes to http://mywebsite.com/?lid=1234
How can I get rid of the / after .com?
It seems like you are doing 2 redirects when a single rewrite should do the trick.
<rule name="test" stopProcessing="true">
<match url="^/?$" />
<action type="Rewrite" url="default.aspx?lid=1234" />
</rule>
If a user comes to http://www.website.com or http://www.website.com/ the url will be rewritten to http://mywebsite.com/default.aspx?lid=1234. (but in the user's browser, the displayed url will stay the same)

Resources