Is there an equivalent to the Apache “Alias” command in Django? - django

I have the following in the .htaccess file of a Django project directory
Alias ^$ app/misc/
Is there a way to accomplish the same thing just using Django (say in the urlconf).
The point of the Alias is that the page actually returned to the user is app/misc/default.html, and all the files that default.html references are in that same directory, which would have to be appended to each file reference in default.html without the alias. Maybe this is commonplace.
Edit:
Don't know what I could have been missing the above doesn't even work.

This is a long-shot and maybe I'm misunderstanding your question. As long as your anchors in default.html are defined as, say, link or link they will be relative to /app/misc/ in this case. However, if you prefix them with a slash like link they will be relative to the root of your web server.
Is that helping you at all?

Related

nginx pretty rewriting one parameter

I have a simple rewrite rule, but I can't get it to work (even with all the other answers here on SO)
I want the user to open this url:
www.example.com/mypage/abcd
and nginx should rewrite it to:
www.example.com/myrealpage/index.html?link=abcd
so actually I want my link parameter nicely embedded in the url.
This is the rule that almost works:
location /mypage {
rewrite ^/mypage/(.*)$ /myrealpage/index.html?link=$1 last;
}
It seems to work for the index.html file, but now all script and css imports are broken . Because every js/script.js or css/style.css becomes rewritten to mypage/abcd/css/style.css which obviously doesn't exist.
FYI:
I apparently need that rewrite mypage → myrealpage because my server provider automatically generates an alias config file that already contains a location /myrealpage so, I don't see any other option than just renaming it to add my own location rule.
How
can I alter that url to rewrite this one link parameter? It is only the one parameter.
You're rewriting every path to your /mypage directory. If you keep your scripts outside in a parent directory you'll be just fine.

In Sitecore 7.2 file upload ,the path is coming as media\test\abc.pdf instead of media/test/abc.pdf

I am trying to add one file from file directory in directory.
While I am clicking on +(insert file) the and selecting a file from directory the path is formed as media\test\abc.pdf instead of media/test/abc.pdf.
Even though chrome is able to resolve the url Firefox is not.
I believe it's because you're using a physical file path that you're getting the backslash. One of the simplest things you can do is a string.Replace() expression to make every backslash a forward slash.
Not sure what your specific use case is, or how much work it would be, but if you're going to use the path on the web and your PDF is located in the MediaLibrary, it might be worth looking into using the URL property of the Sitecore.Data.Items.MediaItem object.

Rewrite first folder to GET param for all php files

I am desperately looking for a rule to achieve the following:
Input URL request would be:
http://myserver.com/param/other/folders/and/files.php
It should redirect to
http://myserver.com/other/folders/and/files.php?p=param
similarly the basic index request
http://myserver.com/param/
would redirect to
http://myserver.com/?p=param
All my php files need the parameter, wherever they are. It'd be nice if JS and CSS files would be excluded but I guess it doesn't really matter since the /file.css?p=param would just be ignored and not cause a problem. I have found rules to map a folder to the GET parameter but none of them are working for php files deeper than the index file on the root level. Thanks so much in advance
Replace
http:\/\/([^\/]+)\/(\w+)\/(.*)
with
http:\/\/\1/\?p=\2\/\3
example regex page at https://regex101.com/r/sU6lR9/1

Is there a "clean URL" (mod_rewrite) equivalent for iPlanet?

I'm working with Coldfusion (because I have to) and we use iPlanet 7 (because we have to), and I would like to pass clean URL's instead of the query-param junk (for numerous reasons). My problem is I don't have access to the overall obj.conf file, and was wondering if there were .htaccess equivalents I could pass on the fly per directory. Currently I am using Application.cfc to force the server to look at index.cfm in root before loading the requested page, but this requires a .cfm file is passed, so it just 404's out if the user provides /path/to/file but no extension. Ultimately, I would like to allow the user to pass domain.com/path/to/file but serve domain.com/index.cfm?q1=path&q2=to&q3=file. Any ideas?
You can mod_dir with the DirectoryIndex directive to set which page is served on /directory/ requests.
http://httpd.apache.org/docs/2.2/mod/mod_dir.html
I'm not sure what exists for iPlanet, haven't had to work with it before. But it would be possible to use a url like index.cfm/path/to/file, and pull the extra path information via the cgi.path_info variable. Not exactly what you're looking for, but cleaner that query-params.

What does this URL mean?

http://localhost/students/index.cfm/register?action=studentreg
I did not understand the use of 'register' after index.cfm. Can anyone please help me understand what it could mean? There is a index.cfm file in students folder. Could register be a folder name?
They might be using special commands within their .htaccess files to modify the URL to point to something else.
Things like pointing home.html -> index.php?p=home
ColdFusion will execute index.cfm. It is up to the script to decide what to do with the /register that comes after.
This trick is used to build SEO friendly URL's. For example http://www.ohnuts.com/buy.cfm/bulk-nuts-seeds/almonds/roasted-salted - buy.com uses the /bulk-nuts-seeds/almonds/roasted-salted to determine which page to show.
Whats nice about this is it avoids custom 404 error handlers and URL rewrites. This makes it easier for your application to directly manage the URL's used.
I don't know if it works on all platforms, as I've only used it on IIS.
You want to look into the cgi.PATH_INFO variable, it is populated automatically by CF server when such URL format used.
Better real-life example would look something like this.
I have an URL which I want to make prettier:
http://mybikesite/index.cfm?category=bicycles&manufacturer=cannondale&model=trail-sl-4
I can rewrite it this way:
http://mybikesite/index.cfm/category/bicycles/manufacturer/cannondale/model/trail-sl-4
Our cgi.PATH_INFO value is: /category/bicycles/manufacturer/cannondale/model/trail-sl-4
We can parse it using list functions to get the same data as original URL gives us automatically.
Second part of your URL is plain GET variable, it is pushed into URL scope as usually.
Both formats can be mixed, GET vars may be used for paging or any other secondary stuff.
index.cfm is using either a CFIF IsDefind("register") or a CFIF #cgi.Path_Info# CONTAINS statements to execute a function or perform a logic step.