I am trying to migrate my testing site, locally.
I am running WAMP with:
Apache 2.2.22
Php 5.3.13
I have added to hosts file:
127.0.0.1 local.testsite.com
I have added to httpd-vhosts.conf (and included it in httpd.conf):
<Directory C:\wamp\www\testsite>
Order Deny,Allow
Allow from all
</Directory>
<VirtualHost *:80>
DocumentRoot "C:\wamp\www\testsite"
ServerName local.testsite.com
</VirtualHost>
And rewrite_module is ON.
I am getting the following error in my local apache error log:
[Sun Oct 26 09:24:17 2014] [alert] [client 127.0.0.1]
C:/wamp/www/testsite/.htaccess: RewriteCond: bad flag delimiters,
referer: http://local.testsite.com/
This is my htaccess file (which worked on my external server):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^dashboard/$ / [R=301,L]
RewriteRule ^dashboard$ / [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?%{QUERY_STRING} [NE,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</IfModule>
Any ideas what could be the problem with my local wamp setup?
Thanks.
I had removed a ton of blank lines from the file (for aesthetic purposes only), when I undid this the htaccess file worked perfectly.
Related
I am experiencing a bizarre apache error. I'd like to rewrite all requests from /api/media/fi/le/path.jpg to /media/fi/le/path.jpg
This are rewrite rules setup in virtual host:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule /api/v1/* /src/api/v1/index.php [L]
RewriteRule /api/media/(.*) /media/$1 [L]
If I point the browser to /media/fi/le/path.jpg, the image gets server successfully. If I go to /api/media/fi/le/path.jpg it complains that I do not have permission to access the resource. I must have permission, because I can access the file if no rewrites are done. How should I rewrite the last RewriteRule so that it would serve the images?
I added logging directive LogLevel alert rewrite:trace6 to see what the apache is doing under the covers. This are the results:
init rewrite engine with requested uri /api/media/32/ee/0e60731bcb220c7c7b.jpg
applying pattern '/api/v1/*' to uri '/api/media/32/ee/0e60731bcb220c7c7b.jpg'
applying pattern '/api/media/(.*)' to uri '/api/media/32/ee/0e60731bcb220c7c7b.jpg'
rewrite '/api/media/32/ee/0e60731bcb220c7c7b.jpg' -> '/media/32/ee/0e60731bcb220c7c7b.jpg'
local path result: /media/32/ee/0e60731bcb220c7c7b.jpg
go-ahead with /media/32/ee/0e60731bcb220c7c7b.jpg [OK]
I can visit the url mydomain.com/media/32/ee/0e60731bcb220c7c7b.jpg manually and the image gets server with no problem. What am I missing?
Complete .conf file for virtual host:
<IfModule mod_ssl.c>
<VirtualHost *:443>
DocumentRoot /home/user/project/src
ServerName project.com
ErrorLog logs/project-error_log
CustomLog logs/project-access_log common
DirectoryIndex index.php
<Directory /home/user/project/src>
Options -Indexes +FollowSymLinks
AllowOverride None
Require all granted
</Directory>
LogLevel alert rewrite:trace6
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule /api/v1/* /api/v1/index.php
RewriteRule /api/media/(.*) /media/$1 [L]
SSLCertificateFile /etc/letsencrypt/live/project.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/project.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/project.com/chain.pem
</VirtualHost>
</IfModule>
There is weird behaviour with rewrite engine.
RewriteRule /api/media/(.*) /media/$1 [L]
Will always return forbidden. After mv media images and changing the above directive to RewriteRule /api/media/(.*) /images/$1 [L], permission error is gone.
I hope that this question is not a duplicate, but I only found articles or questions about this for old versions of Symfony. I am new to Symfony 4 and I would like to create a new application with it and install it as a part of an already existing website (domain below). The Sf 4 app goes into the admin/ subdirectory shown in the hierarchy below. domain uses the TYPO3 CMS, but I’m not sure that it matters for this question.
First, here is the directory structure :
/home/webuser/domain/
public/ (this is the document root for "domain.localhost")
admin/ (the Symfony app goes here)
public/
…
…
typo3/
.htaccess
index.php
…
composer.json
I am currently working on the website on my local machine and I would like to access the Symfony application root from domain.localhost/admin. I am using an Apache virtual host and the domain/public folder is the document root of domain :
<VirtualHost *:80>
ServerName domain.localhost
DocumentRoot "/home/webuser/www/domain/public"
</VirtualHost>
I tried adding the following rewrite rule to my VirtualHost :
<VirtualHost *:80>
ServerName domain.localhost
DocumentRoot "/home/webuser/www/domain/public"
RewriteEngine On
RewriteRule "^/admin/(.*)$" "/admin/public/$1"
LogLevel trace1
</VirtualHost>
But this seems to work only when I visit http://domain.localhost/admin/ : I then see the "Welcome to Symfony 4.2.7" page. As soon as I try to visit a subpage, I get a 404 error. I tried to create my first page at lucky/number as explained in the documentation here, and looking at the Apache error log, I have lines such as :
[Mon Apr 29 18:52:09.472043 2019] [rewrite:trace1] [pid 22250:tid 140404453660416] mod_rewrite.c(483): [client ::1:43084] ::1 - - [domain.localhost/sid#55a33c704bf8][rid#7fb260002bd0/initial] [perdir /home/webuser/www/domain/public/] pass through /home/webuser/www/domain/public/admin/public/lucky
[Mon Apr 29 18:52:09.472087 2019] [core:info] [pid 22250:tid 140404453660416] [client ::1:43084] AH00128: File does not exist: /home/webuser/www/domain/public/admin/public/lucky/number
Now, TYPO3 has an .htaccess file containing URL rewrites, but I don’t think that they are interfering. Below, I just added myself the admin/ folder in the rule after the comment that starts with "Stop rewrite processing", so that we are not redirected to the home page of the domain website when the file is not found :
<IfModule mod_rewrite.c>
# Enable URL rewriting
RewriteEngine On
# Store the current location in an environment variable CWD to use
# mod_rewrite in .htaccess files without knowing the RewriteBase
RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
RewriteRule ^.*$ - [E=CWD:%2]
# Rule for versioned static files, configured through:
# - $GLOBALS['TYPO3_CONF_VARS']['BE']['versionNumberInFilename']
# - $GLOBALS['TYPO3_CONF_VARS']['FE']['versionNumberInFilename']
# IMPORTANT: This rule has to be the very first RewriteCond in order to work!
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ %{ENV:CWD}$1.$3 [L]
# Access block for folders
RewriteRule _(?:recycler|temp)_/ - [F]
RewriteRule fileadmin/templates/.*\.(?:txt|ts)$ - [F]
RewriteRule ^(?:vendor|typo3_src|typo3temp/var) - [F]
RewriteRule (?:typo3conf/ext|typo3/sysext|typo3/ext)/[^/]+/(?:Configuration|Resources/Private|Tests?|Documentation|docs?)/ - [F]
# Block access to all hidden files and directories with the exception of
# the visible content from within the `/.well-known/` hidden directory (RFC 5785).
RewriteCond %{REQUEST_URI} "!(^|/)\.well-known/([^./]+./?)+$" [NC]
RewriteCond %{SCRIPT_FILENAME} -d [OR]
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule (?:^|/)\. - [F]
# Stop rewrite processing, if we are in the typo3/ directory or any other known directory
# NOTE: Add your additional local storages here
RewriteRule ^(?:typo3/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico|admin/) - [L]
# If the file/symlink/directory does not exist => Redirect to index.php.
# For httpd.conf, you need to prefix each '%{REQUEST_FILENAME}' with '%{DOCUMENT_ROOT}'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^.*$ %{ENV:CWD}index.php [QSA,L]
</IfModule>
The production server will be a dedicated system, so I can modify anything I want.
It turns out that I just needed to install the Apache pack, like in this answer
I try to install my Symfony 4 app on a subfolder (on a "dev server") but I have some problems with the apache2 configuration (I'm complete noob with apache)
So here is my structure
My app is installed in /var/www/html/rapp/
I have an apache config file in /etc/apache2/sites-enabled/rapp.confwith the following content
<VirtualHost *:80>
DocumentRoot /var/www/html/rapp/public
<Directory /var/www/html/rapp/public>
AllowOverride All
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /rapp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [L,NC]
</IfModule>
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
# <Directory /var/www/project>
# Options FollowSymlinks
# </Directory>
# optionally disable the RewriteEngine for the asset directories
# which will allow apache to simply reply with a 404 when files are
# not found instead of passing the request into the full symfony stack
<Directory /var/www/html/rapp/public/bundles>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
<Directory /var/www/html/rapp/public/build>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>
On my app root folder (so /var/www/html/rapp/), I have an .htaccess file with the following content to redirect http://xxx.xxx.xxx.xxx/rapp/ url to my app
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /rapp/
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
I have no .htaccess in /var/www/html/rapp/public because it must be handle by the Directory tag in my apache .conf file (I think)
With all that config I have these errors in apache error.log
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
r->uri = /rapp/public/public/public/public/public/public/public/public/public/public/
redirected from r->uri = /rapp/public/public/public/public/public/public/public/public/public/
redirected from r->uri = /rapp/public/public/public/public/public/public/public/public/
redirected from r->uri = /rapp/public/public/public/public/public/public/public/
redirected from r->uri = /rapp/public/public/public/public/public/public/
redirected from r->uri = /rapp/public/public/public/public/public/
redirected from r->uri = /rapp/public/public/public/public/
redirected from r->uri = /rapp/public/public/public/
redirected from r->uri = /rapp/public/public/
redirected from r->uri = /rapp/public/
redirected from r->uri = /rapp/
I don't really understand why it search dor that much of public subfolder.
And finally, what I would like to do is:
When I go to http://xxx.xxx.xxx.xxx/rapp/ it redirects me on my app in /var/www/html/rapp/.
So I want to have the subfolder where the app is installed, but not the public/index.php or public/ part in the URL.
The problem is that your rule's pattern (.*) also matches the destination path /public/$1 and rewrites the destination to itself in loop mode. You need to exclude the destination path in your RewriteRule to avoid the rewrite loop error.
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /rapp/
RewriteRule ^((?!public/).*)$ public/$1 [L]
</IfModule>
Or you can also use a Condition to exclude the destination path
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /rapp/
RewriteRule %{REQUEST_URI} !/public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
On my webserver running Apache/2.2.26 (Unix) DAV/2 PHP/5.4.24 mod_ssl/2.2.26 OpenSSL/0.9.8y I am trying to setup Restler but it can't seem to handle the index.php properly. This is a webapp setup with an httpd.conf that looks like so:
Alias "/dts2" "/usr/local/WebApps/DTS/root"
<Directory "/usr/local/WebApps/DTS/root">
AllowOverride All
Options -Indexes FollowSymLinks
</Directory>
So then I went into that 'root' directory and ran this command to install restler:
composer create-project restler/application=dev-basic api --prefer-dist
After that, in the 'api' directory I created my .htaccess file that looks like so:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ public/index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ public/index.php [QSA,L]
</IfModule>
<IfModule mod_php5.c>
php_flag display_errors On
</IfModule>
And, finally when I try to access "https://..../dts2/api/Home/" to get the success message that restler provides, I get a 404 error.
What have I done wrong?
OK, finally got this working. There were two issues.
One was Restler itself. The supplied index.php said $r->addAPIClass('Home', '');. I had to remove that second empty parameter.
The other was apache. Instead of saying public/index.php on the RewriteRule I had to say /dts2/api/public/index.php.
Once I made those two changes everything worked as expected.
My server isnt loading direct links on its header of html pages.Where dev.pauloxavier.com is an alias for 127.0.0.1. Example:
http://dev.pauloxavier.com/certified/framework/assets/css/custom.css
http://dev.pauloxavier.com/certified/framework/assets/css/bootstrap.css
I cant access this file direct on the browser, either. Error 500 is returned.
On the log of errors i got:
[Mon May 11 12:26:28.724782 2015] [cgi:error] [pid 2864:tid 1828] (9)Bad file descriptor: [client 127.0.0.1:51598] AH01222: don't know how to spawn child process: E:/GitHub/certified/framework/assets/img/favicon.png, referer: http://dev.pauloxavier.com/certified/
My htaccess file:
RewriteEngine On # Turn on the rewriting engine
RewriteBase /certified/
RewriteRule ^user/([a-z]+)/?$ user.php?id=$1 [L]
RewriteRule ^([0-9a-zA-Z-_]{1,100})/?$ index.php?to=$1 [L]
RewriteRule ^import/([0-9a-zA-Z-_]{1,100})/?$ index.php?to=import&id_evento=$1 [L]
RewriteRule ^evento/([0-9a-zA-Z-_]{1,100})/?$ index.php?to=evento&id_evento=$1 [L]
RewriteRule ^inserir/([0-9a-zA-Z-_]{1,100})/?$ index.php?to=inserir&id_evento=$1 [L]
RewriteRule ^remover/([0-9a-zA-Z-_]{1,100})/([0-9a-zA-Z-_]{1,100})/?$ index.php?to=remover&id_evento=$1&id_participante=$2 [L]
RewriteRule ^envio/([0-9a-zA-Z-_]{1,100})/?$ index.php?to=envio&id_evento=$1 [L]
RewriteRule ^certificado/([0-9a-zA-Z-_]{1,100})/([0-9a-zA-Z-_]{1,100})/?$ index.php?to=certificado&evento=$1&particip=$2 [L]
My directory on apache is configured as:
<Directory "E:/GitHub/certified">
AllowOverride All
Require all granted
Allow from all
</Directory>
And using the alias:
ScriptAlias /certified/ "E:/GitHub/certified/"
What is most strange is: This version is working on my webserver, and used to work on my local, but i lost my hd, and had to reinstall everything from scratch. I really think that is a problem with apache, like a misconfig.
Thanks in advance!