I was wondering if there is anything wrong with using html and php files without extensions.
For example, if I was to upload a file with an extension, I would get to by using a URL like this:
http://yoursite.com/randompage.html
If I used a file without an extension, I would use a URL like this:
http://yoursite.com/randompage
I know that this can't be the preferred method because it leaves the file without a way to be identified, but is there anything that would stop the site from working properly?
What you want to do is done with url-rewriting .
Basically, you will add a rewrite rule to your web server, so when he receives a request for url yoursite.com/randompage he will change it to yoursite.com/randompage.html. You will find a lot of examples on the web if you google for "mod_rewrite examples" or "url rewrite examples".
Document types are sent from the webserver in http headers, so it is perfectly possible to do what you are asking.
For instance when using Apache, to tell it that any file with no extension is html, in the 'conf' file you can say:
DefaultType text/html
More details at Apache The Definitive Guide
This point to concrete document (randompage.html in this case):
http://yoursite.com/randompage.html
This point to default document in directory:
http://yoursite.com/randompage/
Default document is set in you webserver. This could be for example: index.html, default.html, index.php, default.apsx,...
Related
I have a specific folder containing ViewerJS that I want to bypass without using .htaccess
The path I want to work is /ViewerJS/#/files/viewfile/version where version is some integer.
The action viewerJS is not defined in AppController
Error: Create AppController::viewerJS() in file: src/Controller/AppController.php.
Is there any way to achieve this using CakePHP routing? I have managed to get this working before with .htaccess but would much prefer a native CakePHP way.
It's really just a way to tell CakePHP to not try to find a controller etc and just treat it as a direct link.
I'm new to React Js and i'm trying to print a file from a url using printJS.
My intention is to access the DB and get a url of pdf file to print, and then print it (without opening a new page if possible).
For testing, after returning with the url i'm just trying to print a local file and not the url given from the db(I assume there might problematic due to security issues, CORS, etc.)
After importing the library into the project i'm trying to do:
printJS('path/to/file/a.pdf');
I don't get any error, and it seems nothing happens, except this warning:
Resource interpreted as Document but transferred with MIME type application/pdf: "blob:http://localhost:3000/18bdc43e-6b53-47ea-91e4-bb62ad76dcc6".
The file exists and when i'm using the url bar and putting path/to/file/a.pdf, i'm able to access the pdf.
https://github.com/crabbly/Print.js/issues/176
Looks like you need to use a domain url instead of a local file path.
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)
www.example.ca/article/563/
I see the above link in a dynamic site. I am working on the site, and there is no folder called 'article' and obviously '563' is dynamically generated as well. I found out I had to edit the article.php page which is located in the root folder to make the changes I wanted, but my question is, how do I make urls appear different from what the actual file location is on the server.
This is commonly called "URL Rewriting". It can be done with appropriate configuration of your webserver, for example Apache's mod_rewrite provides a way to modify incoming URL requests, dynamically, based on regular expression rules.
I've a pdf document in my CAKEPHP webroot. I want to create a route to that pdf file with the name /mydoc. I'm using CAKEPHP 1.3
When we type example.com/mydoc it should open that pdf.
Any direct ways to write direct route and it will be achieved without using controller and action.
If you're using a route, this will have to invoke a controller, in which you may output the PDF using a Cake Media View. That seems rather like overkill though. Instead, just add a URL rewrite rule to app/webroot/.htaccess:
RewriteRule ^/mydoc$ files/the_file.pdf
(Untested, may need some fiddling.) This way the file download is handled by the webserver directly without having to go through Cake.
As of CakePHP 2.9, you can put the following in your routes.php file.
Router::redirect('/mydoc', 'files/mydoc.pdf');