cannot access url string something missing on my code? - apache

I have a problem with apache giving me a "not found" error.
scenario:
I have a url of the form --> 10.17.10.19/webapps/api/index.php?url=auth
I want to rewrite the url in the form --> 10.17.10.19/webapps/api/auth
im Using Ubuntu 20.04 apache2
vhost:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
htaccess:
RewriteEngine On
Options All -Indexes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
apache.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes
# FollowSymLinks
# AllowOverride None
Require all granted
</Directory>
#<Directory /srv/>
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#</Directory>
Please help me to correct the condition to recognize the parameter

i found the answer
i need to enable header so the htaccess can work
ae2enmod header
https://httpd.apache.org/docs/2.4/mod/

Related

Why are sub-directories not found

I have been looking at other answers here on stackoverflow and elsewhere, to no avail.
I am running a virtual-host localhost and the homepage of the site is showing up fine, but if I go to any subdirectory/subpage I see this error:
The requested URL /downloads/ was not found on this server
In sum, mydomain.com works, but mydomain.com/downloads/ does not work.
Usually I have fixed this issue with other domains on my localhost by altering .htaccess. Here is my current setup:
Apache2.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
mydomain.com.lc.conf in sites-available
<VirtualHost *:80>
ServerName mydomain.com.lc
ServerAlias www.mydomain.com.lc
ServerAdmin myemail#mydomain.com
DocumentRoot /var/www/html/mydomain.com.lc/com_mydomain/
SetEnv APPLICATION_ENV local
<Directory /var/www/html/mydomain.com.lc/com_mydomain >
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>
<Directory /var/www/var/www/html/mydomain.com.lc/com_mydomain/*>
Allow from all
Deny from none
Order deny,allow
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
etc/hosts
127.0.0.1 mydomain.com.lc
.htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I've tried using no .htaccess as well.

How to setup Apache to run Laravel rooted from a subpath?

The DocumentRoot of example.com is in /var/www/html.
Laravel is installed in /var/www/example/public and I can access it using http://example.com/dashboard but problem arises when I try to access other routes like as http://example.com/dashboard/login and is throwing 404 Not Found error. And saying The requested URL /var/www/example/public/index.php was not found on this server. Can anyone please guide me?
The .htaccess file in the public directory is untouched.
Here is the 000-default.conf:
ServerName example.com
UseCanonicalName Off
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /dashboard /var/www/example/public
<Directory /var/www/example/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
#dynamic subdomain provisioning
<VirtualHost *:80>
DocumentRoot /var/www/example/public
ServerName user.example.com
ServerAlias *.example.com
<Directory /var/www/example/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
I could solve using the following in the 000-default.conf file:
<Directory /var/www/example/public>
DirectoryIndex index.php
AcceptPathInfo on
AllowOverride All
Options None
Order allow,deny
Allow from all
</Directory>
And had to change the laravel .htaccess in the following way:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /dashboard
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ dashboard/$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

RewriteEngine not allowed here

Some time ago I made a .htaccess file and it worked:
RewriteEngine On
RewriteBase /MVC
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
Now I installed it on another machine and I get the Apache error:
/home/zalmoksis/www/public/MVC-demo/.htaccess: RewriteEngine not allowed here
What may be wrong?
Some relevant Apache configuration around (if you need something more, just say so):
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /home/zalmoksis/www/public
<Directory />
Options FollowSymLinks
AllowOverride FileInfo
</Directory>
<Directory /home/zalmoksis/www/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
and this:
Alias /MVC /home/zalmoksis/www/public/MVC-demo
<Directory /home/zalmoksis/www/public/MVC>
Options FollowSymlinks
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
</IfModule>
</Directory>
Just a thought. Are you sure mod_rewrite.so isn't disabled in httpd.conf?

Apache ErrorDocument issue

i am trying to make my own 403 page but my apache doesn work correct.
I use
ErrorDocument 403
but it shows the same. This is my .htaccess:
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
Here is my host settings:
<VirtualHost 127.0.1.15:80>
ServerAdmin webmaster#localhost
ServerName turik.loc
ServerAlias *.turik.loc
DocumentRoot /home/golars/proj/turik/
<Directory />
Options FollowSymLinks MultiViews
AllowOverride All
</Directory>
<Directory /home/golars/proj/turik/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/t4base_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
To 403 error i am going to turik.loc/img/hotels/ -where i dont have permissions to read&write. I would be graceful for a help.

Problem enabling .htaccess

I'm trying to enable .htaccess files on a Ubuntu server I set up. I changed the sites file from:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
[unnecessary config code omitted]
</VirtualHost>
to
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/document_root
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/document_root>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
[unnecessary config code omitted]
</VirtualHost>
Now when I try to view a page in my browser I get a 500 Internal Server Error. Any ideas as to what my problem may be? Thanks for the help.
EDIT
Here is my .htaccess file:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
I checked the apache error logs as requested and it appears that the error being logged is:
[Fri Jul 10 19:39:12 2009] [alert]
[client 192.168.1.1]
/var/www/document_root/.htaccess:
Invalid command 'RewriteEngine',
perhaps misspelled or defined by a
module not included in the server
configuration
Bah... I didn't have mod_rewrite enabled. I feel stupid.