Apache alias not working, WAMP - css

I am using WAMP.
I edited the httpd.conf file to include:
Alias /static "c:/he/sites/browsbyboodah.com/htdocs/static"
When linking my .css's I use this path:
<link rel="stylesheet" type="text/css" href="/static/css/reset.css" />
I cannot load the .css like this for some reason. What am I forgetting?
Thanks.
/* EDIT */
After a little debugging I found the following from a view page source and clicking on the css file:
Page not found (404)
Request Method: GET
Request URL http://127.0.0.1:8000/static/css/reset.css
css\reset.css could not be found

check whether Apache mod_alias module is installed or not? and remove "
Alias /static/ /sites/browsbyboodah.com/htdocs/static/
alternatively you can use AliasMatch Directive
One subtle difference between Alias and AliasMatch is that Alias
automatically copies any additional part of the URI onto the end of
the file path on the right. AliasMatch does not.
AliasMatch ^/static/(.*)$ /sites/browsbyboodah.com/htdocs/static/$1
Read this article for more help

Related

React app - Blank page for all pages with a dynamic URL, on nginx server

Locally, the app works correctly.
When deploying it on a ubuntu server, there is a problem with this route:
<Route path="/combination/:some_id" exact component={SomePage} />
I'm using a BrowserRouter.
When clicking on a link, the url in the address bar is updated to the correct one, but I'm not redirected to the page.
When trying to access a page (i.e http://my_ip/combination/hjg234jg2323jh4g) all I can see is a blank (white) page.
I think the problem is with nginx configuration, because locally it works. and other routers work (/contact-us)
My /etc/nginx/sites-available/default file contains:
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri /index.html;
}
You need to add only base href="/xyz" in your index.html file.
If you added basename in history, then base href should be equal to
basename or else put only / .
There is no problem in the configuration of the default file.
It's worked well for me.

Expose files to public via rewrite

I'm using nginx docker engine for a symfony app, and I have some images under /var/www/html/project/ezplatform/files/(.*) that i need to expose them to the public.
I tried to add under my nginx configuration this rewrite config:
rewrite "^/var/www/html/project/ezplatform/files/(.*)" "/app.php" break;
rewrite "^/var/www/html/project/ezplatform/files/(.*)" "/var/www/html/project
/ezplatform/files/$1" break;
But still facing an exception 404 Not Found when I try to access to an available image.
Any idea would be appreciated.
Try adding a location block to your nginx conf, where you define a handle for the images directory, which nginx then uses to retrieve files from the full path. Like:
location /other_images/ {
alias /var/www/html/project/ezplatform/files/;
}
You can link to the images using your 'virtual' folder path:
other_images/example.gif
(So in HTML, <img src = "other_images/example.gif">, or use whatever the symfony syntax is for image links.)
Let me know if this solves the 404 Not Found problem.

The default CSS of Django admin section is not loading

Folks, the default CSS of my Django admin section is not loading (setup uses nginx reverse proxy + gunicorn, OS is the Debian-based Ubuntu).
The following is part of etc/nginx/sites-available/myproject:
location /static/admin {
alias /home/mhb11/.virtualenvs/myenv/local/lib/python2.7/site-packages/django/contrib/admin/static/;
}
That, btw, points to the correct location of django admin's css files, and is written below location /static/ {} snippet (not shown here).
Note that I have tried the root directive instead of alias too, to no avail. Also note that this error pertains solely to django admin static files. The project related static files are working perfectly. Also note that my settings.py file includes 'django.contrib.staticfiles', in INSTALLED_APPS and STATIC_URL = '/static/'.
What am I missing? Please ask for more information in case it is needed.
It may not be significant, but for consistency, your location path and alias path should both end with a / or neither end with a /.
With your current configuration, the server is constructing path names with an embedded //, like /home/mhb11/.virtualenvs/myenv/local/lib/python2.7/site-packages/django/contrib/admin/static//somefile.css.
Try:
location /static/admin/ {
alias /home/mhb11/.virtualenvs/myenv/local/lib/python2.7/site-packages/django/contrib/admin/static/;
}

run cgi script using nginx

I am trying to execute cgi script on Nginx. In nginx.conf file, I added a location directive such as below:
location /cgi-bin{
root cgi-bin;
index index.cgi;
}
When I try to connect to http://example.com/cgi-bin/index.cgi, it says file not found. In error.log, I see the request as "http://example.com/html/cgi-bin/index.cgi.
cgi-bin is not in html folder. The correct path is "http://example.com/cgi-bin/index.cgi
I tried many possibilities for location directive. Either it looks in html/cgi-bin or it does /cgi-bin/cgi-bin/index.cgi. I am not sure why it uses 'cgi-bin' twice
Any suggestions.. I have been trying for hours now!!!

How to solve CSS include error after Apache RewriteRule?

I use winXP and AppServ. I have a "showitem.php" on my website root. An example usage:
www.mydomain.com/showitem.php?id=123
I want to use links like following:
www.mydomain.com/item/123
In .htaccess I write this line:
RewriteRule ^item/([^/]+)$ showitem.php?id=$1
Server directs to showitem.php and id is received successfully. However, main problem is with the css and js files. If I make "css/style.css" to "/css/style.css", page is shown on the internet and but not on localhost, because root is "localhost" but files are under "localhost/mydomain". I have also tried "!-f" condition for .css files but it doesn't help and it can't as far as I understand. To solve the problem, I should direct wrong css file interpretation to the correct place, so I want to redirect client request "item/css/style.css" to its original location "css/style.css". I add the following rules for localhost but is there any other way?
RewriteRule ^item/css/([^/]+)$ /mydomain/css/$1
RewriteRule ^item/img/([^/]+)$ /mydomain/img/$1
Set a base tag in your html head.
<base href="http://www.mydomain.com/" />
And then set your stylesheet linking paths relative to the base, e.g.
<link href="css/style.css" />
you could write these to the file .htaccess
ErrorDocument 404 /error_404.php
/error_404.php is your error file you want to put something in there.

Resources