I have a few websites that could benefit from some URL rewriting. I understand that a map file is needed, but as the data is dynamic, is there a way to call from an SQL database instead of a static file?
Using ISAPI Rewrite via IIS7
eg
unfriendly - www.domain.com/products.asp?prodID=1
Friendly - www.domain.com/products/Apples
Any examples or pointers would be apprecaited.
thanks in advance.
C :-)
one possible solution is to do this with a custom 404 handler... when the user hits /products/apples the 404 handler picks it up, does a database lookup and matches that back to prodID=1 and displays the right content.
it's not particularly elegant but it works (I've used it in the past and as long as you remember things like returning the right HTTP response headers for content vs a genuine 404 you should be okay)
Most folks end up using something like ISAPI_Rewrite
Create a new .asp page that retrieves the product using the url name of the product. The new page should be similar to your existing products.asp page but instead of getting the product using the id, you are getting the product using the unique url name.
RewriteRule ^products/(.*)$ /productfromurlname.asp?urlname=$1 [NC,L]
This way:
/products/apples --> /productfromurlname.asp?urlname=apples
/products/oranges --> /productfromurlname.asp?urlname=oranges
Related
I am working on integrating a 2sxc content WebAPI feed into a ReactJS application.
I have managed to get a JSON feed of data into the application, and am in the process of mapping out the data.
I'm wondering what the best practice would be to "resolve" a URL which is coming through as a DNN Page/ Tab ID.
Below I will showcase the various points this is referenced...
First the Setup of the entity / data types...
Then this is an example entry with the data filled out... The page link / URL is set up to point to another internal page on the DNN website:
Finally you can see this data item come through as a JSON feed via the 2sxc API:
What is the best way to convert this piece of data into a URL which can be used in a SPA type application?
There isn't any "server-side" code going on, just reading a JSON feed on the client side...
My initial idea would be to parse this piece of data in JS, to extract the number then use something like this:
http://www.dotnetnuke.com/tabid/85/default.aspx
http://www.dotnetnuke.com/default.aspx?tabid=85
I was hoping someone with more experience would be able to suggest a better / cleaner approach.
Thanks in advance
If you were server-side in Razor you'd be doing something like this:
#using DotNetNuke.Common
View List
XXXX = Dnn.Tab.TabID or define a string with the tab id you want
I seem to have a vague memory that I saw somewhere that Daniel (2sxc) has a way to use Globals.NavigateUrl() or similar on the client side, but I have no idea where or if I did see that.
The Default.aspx?tabid=xx format will certainly work, as it's the oldest DNN convention and is still used in fallbacks. The urls aren't nice, but it's ok.
The reason you're seeing this is because the query doesn't perform the automatic lookup with the AsDynamic(...) does for you. There is an endpoint to look them up, but they are not official, so they could change and therefor I don't want to suggest that you use them.
So if you really want a nicer url, you should either see if DNN has a REST API for this, or you could create a small own 2sxc-api endpoint (in the api folder) just to look that up, then using the NavigateURL. Would be cool if you shared your work.
I'm trying to bake my first CakePHP application and am unable to get any page to particularly load for me right now. I've updated my config settings for salt,database, etc. and the index.php page tells me that I have configured everything.
So far I've used cake bake all on just one database table so far to make sure it loads properly. I created the Model, Controller, and View for the standard add/index/view/edit pages. When I try to access URL/organizations/index.php I'm hitting a 404 error however.
Is there any troubleshooting someone might have advice for how to solve this one? It is confusing to me that the index.php loads (so it redirects properly when loading the webroot) but trying to view any View pages yields no results. Is there any debug commands I can do to view what the valid pages would be? Or any additional information I can provide?
If you try URL/index.php/organisations or something similar to this and it works, then there is an issue with URL re-writing on the server which you'll need to correct.
I believe if you have things set up correctly you would want to visit /organizations in order to access the index() method of the organizations controller.
In general the ".php" is left off of the URL, as your index.php file initiates all the bootstrapping and routing. This also requires a correct .htaccess setup. Hard to say exactly what the problem is without seeing the app or an error message.
Try in url
URL/organizations/index.php
To
URL/organizations/index
or
URL/organizations/index.ctp
Cakephp using .ctp extension, that means cakephp Template. Please see this link. And also you can see your app\view\Organizations folder. Here all file is with .ctp extension. Isn't it ?
I got a small angularJS based website.
I am hosting it via the service OpenShift on some domain like:
bla-blubb.rhcloud.com
Which is of course not that pretty, so I ordered a TLD:
www.supercoolsite.com
from www.united-domains.de. There I habe three possibilities to achieve my goal, see the screen (sorry it is in German - it is: 1) Header redirect, 2) Frame-redirect or 3) URL-Hiding)
But none of these seem to work like I want:
1) Simply redirects the user, so the ugly URL is shown again.
2) Shows my pretty URL, BUT I can't type in like /#/stuff/some/page, it simply does nothing and remains on the start screen. My ngRoute $routeProvider's .when() doesn't trigger that URL like it normally does.
3) Here everything works just fine. I can use Angualr as I'm used to, the above error disappears + the URL is still pretty. BUT: Now I can't send POST Requests with payload to my Java Spring MVC Backend. I get an 415 Error (See second Screen). When using the ugly URL it works perfectly (Everything). It also works using GET methods.
The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.
Does anyone might have an idea? How can I get 2) or 3) working? I don't get what's going wrong.
If code (angular or Spring Controller) is needed, tell me - but as said, it works under DEV and when using the ugly URL.
Thanks!!
A solution for me was to use another (sub) domain like admin.supercoolsite.com, which does a frame redirect to the /#/stuff/some/page URL, automatically triggering my intended behavior.
I have a href link which points to a file on the server but the problem is that it sometimes links to an older version of the file. To be able to access the up-to-date version, i need to clear browsing history/cache. I have tried to clear cache with php, but it doesn't help. Any idea why this is happening, and how to get rid of this problem?
You can add a param to link and force the file download.
link
Multiple ways based on scenarios
Apache Caching directives - If you are the server admin you could use apache's mod_cache to manage caching for specific file(types)
Pass the correct HTML header to the browser directing it not to cache it(its its HTML, PHP etc file where you can control the headers of the request)
Pass a randomly generated number in the end of the url like - url-to-file?1234. where 1234 is a randomly generated number(you could use timestamp also instead of the random number)
in order to make nice urls, I decide to remove the # from my ulrs using the tip from the following question Removing the fragment identifier from AngularJS urls (# symbol) Now, I realized that my urls are not working if I try a direct access to them. from the given example in the related question if put the url below directly in the browser http://localhost/phones
I'll get a 404.
Any idea how to solve this?
You need to write server side code that will generate the page that you were previously depending on the client-side JavaScript to generate.
This will then be the initial view for that URL.
If the client supports JavaScript (and the JavaScript doesn't fail for any reason) it will then take over for future interactions.
Otherwise, the regular links and forms you (should) have in the page will function as normal without JS.