Create folder in symfony root that is not controlled by symfony - symfony

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.

Related

Hide WP-includes, and WP-content/uploads from WordPress

I am using WordPress, I have to hide WP-includes, and WP-content/uploads from WordPress. I have tried to add the below code in htaccess
Options -Indexes
Also, I have referred to this link but still, it's not working for me.
The below link is working
http://localhost:8080/wordpress/wp-includes/
but if I add then I can see all the files. Same for the upload folder
http://localhost:8080/wordpress/wp-includes/assets
http://localhost:8080/wordpress/wp-content/uploads/2022/01
Note-localhost is just an example
Where does the .htaccess file exist on the server? Which path?
Are you sure your web server is processing this file? Are you indeed running Apache?
As long as you have a file named .htaccess (no spaces), and it's placed in your root HTML folder, or within both wp-includes and wp-content folders, and somewhere within the file on its own line, you have Options -indexes, this should be respected for all subfolders and turn off auto-indexing. Can you share the entire contents of this file, perhaps you have placed this line somewhere it's not being read.
After some research, I have created a .htaccess file in the wp-content/uploads and added the below code. And it's started working
# Kill PHP Execution
<Files ~ ".ph(?:p[345]?|t|tml)$">
deny from all
</Files>

Wordpress Apache2 mod_speling not working

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.

How to shorten a url in .htaccess file

I have a wordpress website with the integration of a laravel5.1 app. I use a couple views from the laravel app. How can I shorten the the following url
http://wordpressapp.com/laravel-app/public/item/view/18
I would like to remove /larave-app/public/ from the url so that when they click on the link the url shows as
http://wordpressapp.com/item/view/18
I am not sure if I need to update the .htaccess file in the laravel-app/public folder or the .htaccess file in wordpress or in both files. Thanks
I'm not an .htaccess expert but I know this trick has worked for me in the past:
RewriteRule ^laravel-app/public/(.*)$ /$1 [L,NC,R]
I imagine that the .htaccess file in the root of the site (WP) would need to be edited for this. I'm not sure what impact the "L" in the rule will have on the laravel app, perhaps it's worth giving it a try and testing?
This site: https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/ has some interesting explanations for you if you need more customisation.

Symfony directory structure on cPanel site

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!

Best way to serve static resource (CSS, Images) with XDV in Plone

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"

Resources