I have tried to install silverstripe 4.2.1 on two different servers and am getting the same error on install.. I have multiple installations this year on other client machines but this is the first time I have run into this problem. Wondering if it is a 4.2.1 problem
The error message on installation
Friendly URLs are not working. This is most likely because a rewrite module isn't configured correctly on your site. You may need to get your web host or server administrator to do this for you:
mod_rewrite or other rewrite module is enabled on your web server
AllowOverride All is set for the directory where SilverStripe is
installed
I have placed some garbage text in .htaccess at root, in public_html and in the silverstripe public folder. All three cause a 500 error.
Note that i was able to visit site.com and it redirected to the installer. so I would think that mod_rewrite is indeed enabled.
When I visit site.com it gives the silverstripe version of "Server Error"
My HTAccess file located in the public folder of SS:
### SILVERSTRIPE START ###
# Deny access to templates (but allow from localhost)
<Files *.ss>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files>
# Deny access to IIS configuration
<Files web.config>
Order deny,allow
Deny from all
</Files>
# Deny access to YAML configuration files which might include sensitive information
<Files ~ "\.ya?ml$">
Order allow,deny
Deny from all
</Files>
# Route errors to static pages automatically generated by SilverStripe
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html
<IfModule mod_rewrite.c>
# Turn off index.php handling requests to the homepage fixes issue in apache >=2.4
<IfModule mod_dir.c>
DirectoryIndex disabled
DirectorySlash On
</IfModule>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteBase '/public'
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Deny access to potentially sensitive files and folders
RewriteRule ^vendor(/|$) - [F,L,NC]
RewriteRule ^\.env - [F,L,NC]
RewriteRule silverstripe-cache(/|$) - [F,L,NC]
RewriteRule composer\.(json|lock) - [F,L,NC]
RewriteRule (error|silverstripe|debug)\.log - [F,L,NC]
# Process through SilverStripe if no file with the requested name exists.
# Pass through the original path as a query parameter, and retain the existing parameters.
# Try finding framework in the vendor folder first
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
</IfModule>
### SILVERSTRIPE END ###
And the one in public_html
RewriteEngine On
RewriteRule ^(.*)$ public/$1
I am running PHP7.1 on a shared server.
I want to post this here in case someone else runs into this problem. It has plagued me for 4 days now and no one seems to have an answer.
If you install SS on a shared hosting account by either unzipping the source into public_html or by composer you may run into an error on install.
Not able to write friendly urls - check that mod_rewrite is enabled and that AllowOveride is set to All.
I knew that both of those were in fact on after talking to tech support.
When visiting the site after the error on install I would get a server error after some testing could see that the site was indeed rewriting to /public as intended by SS.
Finally I noticed that index.php in /public had permissions of 775. I changed it to 644 and all is well.
Note: I tried installing v4.2.1 on two different hosting providers. BlueHost (has ssh access for composer) and Hostgator(no ssh)Both gave me the same problem
Related
In development mode, I use an apache server, I go to my App via localhost/myApp/public/index.php . I want test prod mod with my symfony 4 application.
I changed the APP_ENV variable to "prod" (in the .env file)
I installed composer packages via the command composer install --no-dev
But now, when I open my browser and go to localhost/myApp/public/index.php, I get a symfony 404 error page :
The apache configuratin seems good (I can access to the website without any problems in dev mode and I get a 404 not found built by symfony, the index.php is found by apache). I don't understand where may be the problem :/
EDIT : below, the content of the .htaccess file (in the public directory). I don't modify it, this is the symfony default htaccess file :
# Use the front controller as index file. It serves as a fallback solution when
# every other rewrite/redirect fails (e.g. in an aliased environment without
# mod_rewrite). Additionally, this reduces the matching process for the
# start page (path "/") because otherwise Apache will apply the rewriting rules
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex index.php
# By default, Apache does not evaluate symbolic links if you did not enable this
# feature in your server configuration. Uncomment the following line if you
# install assets as symlinks or if you experience problems related to symlinks
# when compiling LESS/Sass/CoffeScript assets.
# Options FollowSymlinks
# Disabling MultiViews prevents unwanted negotiation, e.g. "/index" should not resolve
# to the front controller "/index.php" but be rewritten to "/index.php/index".
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
# Determine the RewriteBase automatically and set it as environment variable.
# If you are using Apache aliases to do mass virtual hosting or installed the
# project in a subdirectory, the base path will be prepended to allow proper
# resolution of the index.php file and to redirect to the correct URI. It will
# work in environments without path prefix as well, providing a safe, one-size
# fits all solution. But as you do not need it in this case, you can comment
# the following 2 lines to eliminate the overhead.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
# Sets the HTTP_AUTHORIZATION header removed by Apache
RewriteCond %{HTTP:Authorization} .
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect to URI without front controller to prevent duplicate content
# (with and without `/index.php`). Only do this redirect on the initial
# rewrite by Apache and not on subsequent cycles. Otherwise we would get an
# endless redirect loop (request -> rewrite to front controller ->
# redirect -> request -> ...).
# So in case you get a "too many redirects" error or you always get redirected
# to the start page because your Apache does not expose the REDIRECT_STATUS
# environment variable, you have 2 choices:
# - disable this feature by commenting the following 2 lines or
# - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
# following RewriteCond (best solution)
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
# If the requested filename exists, simply serve it.
# We only want to let Apache serve files and not directories.
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
# Rewrite all other queries to the front controller.
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
# When mod_rewrite is not available, we instruct a temporary redirect of
# the start page to the front controller explicitly so that the website
# and the generated links can still be used.
RedirectMatch 307 ^/$ /index.php/
# RedirectTemp cannot be used instead
</IfModule>
</IfModule>
Edit 3 : I created the php file foo.php in the dir public with <?php echo 'foo';?> and I can access to this file through my browser without any problem. Something is wrong with symfony but impossible to find where is my error...
Thank you for any help !
I am so stupid. In dev mode, the home page ('/') doesn't show a 404 but a page generated automatically by symfony.
The reason of why I have a 404 in prod mode is I don't create a controller with a route for the path '/'.
So, this 404 in home page in prod env is just logical
I am new to Wordpress but tried all documentation and Stack Overflow posts for possible solutions but none of them have worked so far.
I have verified that mod rewrite is enabled and working as expected. Followed all steps mentioned here. https://wordpress.stackexchange.com/questions/105795/remove-index-php-from-permalinks
Also restarted Apache couple of times but still getting 404 errors when I remove index.php path from Permalink Settings.
Renamed the wordpress directory to blog to access the site at www.xyz.com/blog. Now the requirement is to access any blog posts with
www.xyz.com/blog/2018/02/09/my-wp-post without index.php in the URLs.
We don't have any other CMS content other than WP for the blog site.
Permalink settings(Custom Structure):
/index.php/%year%/%monthnum%/%day%/%postname%/
.htaccess file contents:
BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
I spent ton of time trying many different approaches answered here or elsewhere but none of them fixed my issue.
This is what I did and it has fixed my issue.
Change permalink settings to remove index.php
Update/Save .htaccess content that's at the root of the WP installation if it's not allowed to be updated automatically when we change permalink settings in WP admin panel.
This is the important step since not many Q & A mentioned this in detail, other than wordpress documentation here. Specifically check AllowOverride settings and change it to All, Apache httpd.conf will not load the .htaccess contents without this change. Of course mod_rewrite must be enabled in the server if it's not already done. In our case it's enabled by default, so didn't have to mess with this step.
Also make sure FollowSymLinks option enabled as mentioned in the WP documentation.
Last but not least, make sure you restart the Apache service/server for the changes to take effect.
Entry in httpd.conf file:
<Directory "/var/www/html/blog">
Options FollowSymLinks
AllowOverride All
Assuming Ubuntu 16.04 & Apache2
1) Activate mod_rewrite. It's available but not enabled with a clean Apache 2 installation.
sudo a2enmod rewrite
2) Restart Apache
sudo systemctl restart apache2.service
3) Setup .htaccess
(Note: Apache reccomends using a server configuration file over inserting rules into .htaccess, however, for this example, inserting rules into .htaccess is sufficient because of the negligible performance hit.)
sudo nano /etc/apache2/sites-available/000-default.conf
Insert the following in 000-default.conf
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
4) Restart Apache
Repeat step 2
5) Create .htaccess in the web root.
touch /var/www/html/.htaccess
Insert the following into .htaccess
RewriteEngine On
6 Configure the URL Rewrite (Note: Assuming index.php)
sudo nano /var/www/html/.htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
mod_rewrite is a useful Apache module that can be used effectively to ensure human-readable URLs and good SEO results. If you'd like to learn more about mod_rewrite, take a look at Apache's mod_rewrite Introduction and Apache's official documentation for mod_rewrite.
In a nutshell, as #Cnu as mentionned, the problem very few resources on the internet touch on is the fact that your apache configuration must contain an AllowOverride FileInfo directive for wordpress rewrites to work without /index.php/.
Since Apache 2.4, AllowOverride default setting is "None", which is often a roadblock in making "pretty urls" work (in this case ditching the index.php). As #cnu mentionned, you should read carefully this resource : https://wordpress.org/support/article/using-permalinks/.
Make sure to have mod_rewrite enabled
-> (to be sure create an info.php you will remove later containing the line <?php phpinfo();?>) at the root of your blog and call https://domainofyourb.log/info.php)
Make sure your .htaccess is writable by wordpress. (permission and ownership should be allowing your webserver (often with the username "apache") to edit the file.
Change your wordpress permalinks settings, and check that .htaccess file is correctly written.
Check that your apache configuration (etc/httpd/conf/httpd.conf in some linux distros) contains the directive AllowOverride FileInfo within your blog's <Directory></Directory> section
Options directive to FollowSymLinks should be the default, but if Options directive is mentionned, add FollowSymLinks for good measure.
when all that is done, don't forget to restart your Apache server. (sudo service httpd restart in my case, ymmv).
P.S : wrote this answer because I can't comment (don't have rep) on cnu's answer, and wanted to correct 1. allowoverride doesn't need to be set to ALL, it can be set to simply "FileInfo", 2. update the link to wordpress doc, and 3. provide background on the change in apache 2.4 that causes this issue.
Go to admin page, Dashboard -> Settings -> Permalink Settings -> Custom Structure, select /%postname%/ or, /%year%/%monthnum%/%day%/%postname%/ up to you.
I have a variation on the old WordPress problem regarding permalinks failing (404 errors) when permalinks are set to anything other than 'plain' (where plain = http://example.com/?p=123 and a 'pretty' URL = http://example.com/sample-post/ - taking the URL content from the article title, for example).
For the first time I am starting a site on a virtual rather than dedicated server (Hetzner hosted), where I at least was able to easily read the httpd.conf settings and other server configurations.
To recap here, the problem is that neither WordPress nor the default server settings are usually ready for the URL rewriting that allows 'pretty' URLs out of the box. When confronted with this problem before, on dedicated servers, I would ensure that AllowOverride was set to 'all' or '[directory]' and then would put in an .htaccess file into the web's document root with this traditional solver:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
However this does not work on my Hetzner server. I put in the above code to an .htaccess file, set the permissions correctly and restarted. But the front page still shows links to the article lists, but the articles themselves all still throw that old 404 error.
The only access I have to the core server directives is drip-fed out in sections and radio-buttons etc via Plesk. I can't even open up the httpd settings read only to see how AllowOverride is set. Hetzner consider this a 'software problem', and therefore unsupported.
There is a section in Plesk where you can add additional Apache and Nginx directives (with duplicate boxes for http and https for Apache). I tried this in the Apache boxes and rebooted, but it didn't help (obviously this is not the actual URL I wrote):
<Directory "/var/www/vhosts/example.com/httpdocs/">
AllowOverride All
</Directory>
If anyone has any suggestions as to how I can get the usual rewrite fix in, in these circumstances, it would be much appreciated.
Okay, the problem was an obscure one, as it turned out. The virtual server was running Nginx on top of Apache, and I needed to install a plugin via Plesk which provides an 'ht access translator' for Nginx in Plesk. I pasted the rewrite directives there, they were 'translated' to Nginx-understandable commands, and the problem is solved.
As a symfony1.4 developer, I'm trying to learn Symfony2.
Now, instead of trying on my local machine, where all works fine, today I want to make my test site available on my server. But I don't want to deploy it on a real site or on a real subdomain.
And that's my question: how can I deploy this test on a subfolder without modify virtualhost?!
Lets say I have an available site, www.example.com, but I'd like to have my symfony test available (and working correctly) here www.exaple.com/mysymfonytest
Did somone already do that?
Thanks...
In my opinion that is not really a symfony related question.
Depending on your webserver you could configure an alias where which url should point.
In Apache you specify your document root, where you put your sf2 installation, and then define an alias which would be /mysymfonytest pointing to that document root.
Alternatively you could specify your document root, leave the url be and define a prefix for all routes in symfony, which you would do in your routing configuration.
I strongly recommend configuring your webserver though.
For example in apache:
<VirtualHost *:80>
DocumentRoot /var/www/mysymfonytest
Alias /mysymfonytest /var/www/mysymfonytest
<Directory /var/www/mysymfonytest/web>
AllowOverride None
Order allow,deny
Allow from all
#Allow from <SUPPORT>
RewriteEngine On
RewriteBase /mysymfonytest
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app.php [QSA,L]
</Directory>
</VirtualHost>
Alternatively, if you cannot add the VHost:
How to add a prefix to all my routes
make a sub-directory under / (root directory) and call it mysymfonytest then put your symfony2 project in mysymfonytest.
add a .htaccess file to mysymfonytest folder and put in it :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ web [L]
</IfModule>
or you can just make a file named index.html and make it point to app.php
If your only running on a shared hosting. You could use override configurations using .htaccess. Ask your provide if they allow overrides and then provide them the script or tell them what you want. Hope that's covered on your hosting support.
I have a wordpress install with the following htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/secure-area/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
and a directory /public_html/secure-area/ which has been protected using cPanel.
If I turn off prettylinks in Wordpress, I can access the directory normally, but otherwise, I am redirected to the WP 404 page.
I can access a directory that is not password protected without any problems.
I'm asking here because this is an htaccess problem, not just wordpress specific, and the answers I've seen over here seem better qualified.
Many thanks, Tim
Similar questions which don't address password protected directories:
https://wordpress.stackexchange.com/questions/7181/wordpress-overriding-actual-subdirectories
https://wordpress.stackexchange.com/questions/20152/cannot-access-non-wordpress-subdirectories-as-wordpress-overrides-them-with-a-404
Can't access my folder because of WordPress
I was having the same problem and this worked for me: http://support.aiso.net/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=246
Just switch the 401 Error Document line to read:
ErrorDocument 401 default
The 404 is from not having "401" Error document - one is specified by default with cpanel but not usually not set up by the host. I created a blank document and added this to my .htaccess:
ErrorDocument 401 /empty.html
I did this to protect my wp-admin folder from future/unknown Wordpress exploits after someone defaced my site.
I had this same problem under cPanel. In my case it was due to the "~/.htpasswds/public_html/secure-dir/passwd" file/directory not having the correct permissions. I called the hosting company and they chown'd the file with the correct permissions and it worked.
It really had me stumped in that it looked like the directory protection was working b/c it was popping up the AUTH window. But when Apache went to verify the passwd it would choke and serve the WP standard 404 page.
I'm still interested in solving this, because I'd like a portable solution, but my workaround is that I've removed password protection and restricted access to my own IP address.
I added an htaccess file in the /secure-area/ directory with the following code from Perishable Press - Studpid htaccess tricks:
# deny all except those indicated here
<Limit GET POST PUT>
order deny,allow
deny from all
allow from x.x.x.x
allow from .*domain\.com.*
</Limit>
I've got a few scripts i run in there, so i also add:
# enable directory browsing
Options All +Indexes
for ease of use, given that it (should be) a secure directory.
I'm interested in hearing whterh this is a silly, insecure way of going about things :) Ta
ErrorDocument 401 default
Add this as the first line in htaccess. Worked for my wordpress site which kept redirecting to 404 page.