I have tried several ways to serve my static resources from Plone with XDV:
Putting the CSS and images in the Custom folder - files are 404 not found
Serving them from Apache and setting the Absolute URL Prefix in the XDV config - works, but any other relatively URL'd links (e.g. PDF files in my content) get prefixed as well and therefore are 404 not found
Setting browser:resourceDirectory - 404 not found
Setting cmf:registerDirectory - 404 not found
Any suggestions? I've turned the log level to DEBUG but this doesn't give me any clues.
You just need to put your css/js in the "static" directory and than use relative path in the index.html. Diazo/XDV will automagically remap relative paths.
Or you can also register a resourceDirectory in the usual way and than link files like so "++resource++myresourcedirid/my.css"
See an example here.
I managed to use static content served by Apache using mod_rewrite and the following rules in Apache Virtual Host configuration.
RewriteRule ^/css - [L]
RewriteRule ^/img - [L]
I have also used Giacomo method for specific Plone content style with the static directory in my package which is linked in the "index.html" as "++resource++mypackage.theme/plone.css"
Related
I made a nodejs-express project which have some static html content and styles.
I used express-static like this to get assets file :
app.use(express.static(__dirname + '/views/assets'));
This works fine when I start a node server like this: node server.js
But I have a GoDaddy shared hosting with apache2 pre-configured and I have to get rid of the port on which this node server started and I can't use port 80 as there are other static pages already hosted on that server.
So, I added a .htaccess file in root of the project dir :
RewriteEngine on
RewriteRule (.*) http://localhost:8080/ [P,L]
This is redirecting the page to http://www.example.com/myproject/ but the static files like css and js added in ejs files are getting 404. They got the path like www.example.com/css/main.css, wherein local scenario the css files would be found in http://localhost:8080/css/main.css
Can I add a proxy in .htaccess to achieve this
How can I fix the problem without removing express-static or changing css and js paths to relative?
I am in the process of migrating my site to Wordpress from IIS.
I have run into an issue:
I have URL's that are a mix of upper and lower case that reference images. These URL's are getting a 404 because the case of the URL does not match the case of the file location.
For example, in my article I have a URL:
https://aaa.bbb.com/wp-content/migrate/ABC/abc.png
The file this is referencing is: /var/www/aaa/wp-content/migrate/abc/abc.png
When I change the URL to the same case as the file, it works, however how can I make it ignore the case of the folder on disk?
I tired the mod_speling module by putting this into /etc/apache2/apache2.conf but this just does not work for me. Also tried putting this into .htaccess in the root of my web directory but that made no difference.
<IfModule mod_speling.c>
CheckSpelling On
CheckCaseOnly On
</IfModule>
I have read various threads on here but I'm completely stuck.
I managed to find a work around to this.
I ended up writing a rewrite rule in the VirtualHost file to rewrite everything to lowercase apart from anything within the directory of assets imported from Windows.
I'm building my first Symfony site that will eventually be hosted on a shared server/cPanel site.
I'd like to have my Symfony/web content separate from the server files, though the way Symfony is structured, all the Symfony files are outside the public_html folder. But with a cPanel setup, there's already a lot of files and folders outside the public_html folder (mail, logs, .bashrc, .cpanel, www alias... and a dozen others).
I worry that it feels messy if I put Symfony mixed in with all these files and there could be a conflict. I would rather it be in a directory by itself. The best idea I've had so far is to make a subdomain to host Symfony where I can manually choose the web folder, and then just do redirects to the subdomain.
What do others do?
This is how I decided to do it, and it seems like it will work pretty well. I just use the regular cPanel public_html as the document root, upload the whole Symfony contents to that directory, but then add an .htaccess file with the contents:
RewriteEngine on
RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) /web/$1 [L]
And that protects the main Symfony contents from public access while at the same time putting it all in a directory by itself. It seems to work so far. If anyone has a better idea, I'm open to it!
Where exactly is the dev/build and dev/tasks directories in a Silverstripe installation? Is is in the Framework directory? Or should I create them if they are missing? Also how do I create an instance of a ORM Dataobject without using create?
There are no directories, they are in the URL and then the URL gets parsed by silverstripe, see in your .htaccess for something like...
RewriteRule .* framework/main.php?url=%1&%{QUERY_STRING} [L]
...this line (and some previous) indicate that the URL is passed to the main.php and then it is parsed.
This process is called URL rewriting there is a good introduction here https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
Silverstripe calls this configuration routing (so route certain URLS to certain controllers) and is documented here https://docs.silverstripe.org/en/3.2/developer_guides/controllers/routing/
The "dev" url segment maps to DevelopmentAdmin in the routes.yml
I want to create http://localhost/Symfony/temp/.
In temp will be a basic index.html and some images. If I create the folder right now and put the index.html file in /temp/ I get a 404.
How do I get a normal response from http://localhost/Symfony/temp/index.html?
Requests going to temp/ are being caught by Symfony's default .htaccess. You'll have to add following:
# allow access to temp
RewriteRule ^temp.* - [QSA,L]
If you want it to work even with app_dev.php just change it to ^[app_dev.php/]*temp.*.
But I'm more interested why do you want to do that in root directory and not in static files directory (eg. web/static/temp). You wouldn't need to mess around with .htaccess and you'd be able to link to such images with asset(...).
Here's the solution I eventually came up with.
All I did was create a .htaccess file in /temp/ and inserted:
allow from all
Since I was getting a 404 error and all the other symfony folders had a .htaccess with
deny from all
I reversed engineered an answer.
Hope this helps someone else.