Today I went from my Windows server to Ubuntu. I transferred my Laravel project that I had on IIS to apache2 and installed mod rewrite. However, I can't see the pages. This is the error I get: View [pages.maintenance] not found.
This is what I added to the 000-default.config configuration file:
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</ Directory>
This is my htaccess (found in /var/www/html/public, (my DirectoryRoot):
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</ IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond% {HTTP: Authorization}.
RewriteRule. * - [E = HTTP_AUTHORIZATION:% {HTTP: Authorization}]
# Redirect Trailing Slashes If Not A Folder ...
RewriteCond% {REQUEST_FILENAME}! -D
RewriteCond% {REQUEST_URI} (. +) / $
RewriteRule ^% 1 [L, R = 301]
# Handle Front Controller ...
RewriteCond% {REQUEST_FILENAME}! -D
RewriteCond% {REQUEST_FILENAME}! -F
RewriteRule ^ index.php [L]
</ IfModule>
How come I get this? I checked the rewritten mod change and it's okay.
Related
I'm new to mod_rewrite, but I have successfully set up an Apache 2.4 Reverse Proxy (doesn't use <directory>). However, now I need to redirect two literal paths (app1 and app2 to app1/ and app2/):
https://external.com/app1 to https://internal.com/app1/ (with the slash)
https://external.com/app2 to https://internal.com/app2/ (with the slash)
where app1/ and app2/ are
ProxyPass "/app1/" "https://internal.com/app1/"
ProxyPassReverse "/app1/" "https://internal.com/app1/"
ProxyPass "/app2/" "https://internal.com/app2/"
ProxyPassReverse "/app2/" "https://internal.com/app2/"
I've tried variations on these, but they cause loops or otherwise don't work.
RewriteEngine On
RewriteRule ^/(app1)$ $1/ [PT]
RewriteRule ^/(app2)$ $1/ [PT]
Thoughts? Again, I don't know mod_rewrite well.
I got this working with redirect instead of mod_rewrite:
Redirect /app1 /app1/
Redirect /app2 /app2/
I am using apache2.4 on ubuntu 14.04. And I have enabled mod_proxy_html.But my URL are not getting replaced by a new one. Same thing I did in apache2.2 and it was working perfectly. This is my Virtual host file.
<VirtualHost *:80>
ServerAdmin webmaster#example.com
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/html/www.example.com
LogLevel error
CustomLog /var/log/apache2/www.example.com_access.log combined
ErrorLog /var/log/apache2/www.example.com_error.log
#Proxy and cookies settings
ProxyPreserveHost On
ProxyPassReverse / http://www.example.com/example/control/
ProxyPassReverse / https://www.example.com/example/control/
ProxyPassReverse / /example/control/
ProxyPassReverseCookiePath /example /
<Proxy balancer://cluster>
BalancerMember ajp://10.14.78.45:8009 route=node01 keepalive=On loadfactor=1 ping=10 ttl=600
ProxySet timeout=60 stickysession=JSESSIONID nofailover=On
</Proxy>
RewriteEngine On
#redirect non www domain to www domain
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com$1 [R=301,L]
#Website
RewriteRule ^/;(.*)$ balancer://cluster/example/control/main;$1 [P,L]
RewriteRule ^/$ balancer://cluster/example/control/main [P,L]
SetOutputFilter INFLATE;proxy-html;DEFLATE
ProxyHTMLExtended Off
ProxyHTMLInterp On
ProxyHTMLDoctype XHTML Legacy
LogLevel debug
#Rewrite home page link
ProxyHTMLURLMap ^(.*)/example/control/main;(.*)$ $1/;$2 [R]
ProxyHTMLURLMap ^(.*)/example/control/main$ $1/ [R]
I guess ProxyHTMLURLMap is not working here. Please let me know if something is not configured properly.
Thanks
After hours of research I got simple solution with little luck.
proxy_html.conf file was missing. I have copied this file from apache2.2 to /etc/apache/mods-available and made link in mods-enabled pointing to this file.
vi /etc/apache2/mods-available
added these lines:
# Here's the declaration for W3C HTML 4.01 and XHTML 1.0
ProxyHTMLLinks a href
ProxyHTMLLinks area href
ProxyHTMLLinks link href
ProxyHTMLLinks img src longdesc usemap
ProxyHTMLLinks object classid codebase data usemap
ProxyHTMLLinks q cite
ProxyHTMLLinks blockquote cite
ProxyHTMLLinks ins cite
ProxyHTMLLinks del cite
ProxyHTMLLinks form action
ProxyHTMLLinks input src usemap
ProxyHTMLLinks head profile
ProxyHTMLLinks base href
ProxyHTMLLinks script src for
# To support scripting events (with ProxyHTMLExtended On),
# you'll need to declare them too.
ProxyHTMLEvents onclick ondblclick onmousedown onmouseup \
onmouseover onmousemove onmouseout onkeypress \
onkeydown onkeyup onfocus onblur onload \
onunload onsubmit onreset onselect onchange
creating link in mods-enabled
ln -s /etc/apache2/mods-available/proxy_html.conf /etc/apache2/mods-enabled/
After that it worked perfectly
I just updated my ubuntu to 14.04 and my apache to 2.4.7.
Now when I access any of my webpages on my server, images load for a second, then appear broken.
.htaccess:
RewriteEngine On
# Serve the favicon file from img folder
RewriteCond %{REQUEST_URI} ^/favicon.ico$
RewriteRule ^(.*)$ /img/$1 [NC,L]
# Redirect HTTP traffic to WWW subdomain
RewriteCond %{HTTPS} off [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# Redirect HTTPS traffic to WWW subdomain
RewriteCond %{HTTPS} on [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
# Auto Versioning rules
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)\.[\d]+\.(css|js)$ $1.$2 [L]
# Default Zend rewrite rules
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
VHost:
ServerAdmin admin#localhost
ServerName localhost
DocumentRoot /home/mihai/ARTD/www/public/website
<Directory /home/mihai/ARTD/www/public/website >
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
<IfModule mod_php5.c>
php_value memory_limit 128M
php_value upload_max_filesize 20M
php_value post_max_size 20M
</IfModule>
ErrorLog /var/log/apache2/ARTD-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/ARTD-access.log combined
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin admin#localhost
ServerName localhost
DocumentRoot /home/mihai/ARTD/www/public/website
# Omit this in production environment
SetEnv APPLICATION_ENV local
<Directory /home/mihai/ARTD/www/public/website >
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
<IfModule mod_php5.c>
php_value memory_limit 128M
php_value upload_max_filesize 20M
php_value post_max_size 20M
</IfModule>
ErrorLog /var/log/apache2/ARTD-ssl-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/ARTD.log combined
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# A self-signed (snakeoil) certificate can be created by installing
# the ssl-cert package. See
# /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
# If both key and certificate are stored in the same file, only the
# SSLCertificateFile directive is needed.
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
# Server Certificate Chain:
# Point SSLCertificateChainFile at a file containing the
# concatenation of PEM encoded CA certificates which form the
# certificate chain for the server certificate. Alternatively
# the referenced file can be the same as SSLCertificateFile
# when the CA certificates are directly appended to the server
# certificate for convinience.
#SSLCertificateChainFile /etc/apache2/ssl.crt/server-ca.crt
# Certificate Authority (CA):
# Set the CA certificate verification path where to find CA
# certificates for client authentication or alternatively one
# huge file containing all of them (file must be PEM encoded)
# Note: Inside SSLCACertificatePath you need hash symlinks
# to point to the certificate files. Use the provided
# Makefile to update the hash symlinks after changes.
#SSLCACertificatePath /etc/ssl/certs/
#SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt
# Certificate Revocation Lists (CRL):
# Set the CA revocation path where to find CA CRLs for client
# authentication or alternatively one huge file containing all
# of them (file must be PEM encoded)
# Note: Inside SSLCARevocationPath you need hash symlinks
# to point to the certificate files. Use the provided
# Makefile to update the hash symlinks after changes.
#SSLCARevocationPath /etc/apache2/ssl.crl/
#SSLCARevocationFile /etc/apache2/ssl.crl/ca-bundle.crl
# Client Authentication (Type):
# Client certificate verification type and depth. Types are
# none, optional, require and optional_no_ca. Depth is a
# number which specifies how deeply to verify the certificate
# issuer chain before deciding the certificate is not valid.
#SSLVerifyClient require
#SSLVerifyDepth 10
# Access Control:
# With SSLRequire you can do per-directory access control based
# on arbitrary complex boolean expressions containing server
# variable checks and other lookup directives. The syntax is a
# mixture between C and Perl. See the mod_ssl documentation
# for more details.
#<Location />
#SSLRequire ( %{SSL_CIPHER} !~ m/^(EXP|NULL)/ \
# and %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \
# and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"} \
# and %{TIME_WDAY} >= 1 and %{TIME_WDAY} <= 5 \
# and %{TIME_HOUR} >= 8 and %{TIME_HOUR} <= 20 ) \
# or %{REMOTE_ADDR} =~ m/^192\.76\.162\.[0-9]+$/
#</Location>
# SSL Engine Options:
# Set various options for the SSL engine.
# o FakeBasicAuth:
# Translate the client X.509 into a Basic Authorisation. This means that
# the standard Auth/DBMAuth methods can be used for access control. The
# user name is the `one line' version of the client's X.509 certificate.
# Note that no password is obtained from the user. Every entry in the user
# file needs this password: `xxj31ZMTZzkVA'.
# o ExportCertData:
# This exports two additional environment variables: SSL_CLIENT_CERT and
# SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
# server (always existing) and the client (only existing when client
# authentication is used). This can be used to import the certificates
# into CGI scripts.
# o StdEnvVars:
# This exports the standard SSL/TLS related `SSL_*' environment variables.
# Per default this exportation is switched off for performance reasons,
# because the extraction step is an expensive operation and is usually
# useless for serving static content. So one usually enables the
# exportation for CGI and SSI requests only.
# o StrictRequire:
# This denies access when "SSLRequireSSL" or "SSLRequire" applied even
# under a "Satisfy any" situation, i.e. when it applies access is denied
# and no other module can change it.
# o OptRenegotiate:
# This enables optimized SSL connection renegotiation handling when SSL
# directives are used in per-directory context.
#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
#<FilesMatch "\.(cgi|shtml|phtml|php)$">
# SSLOptions +StdEnvVars
#</FilesMatch>
# SSL Protocol Adjustments:
# The safe and default but still SSL/TLS standard compliant shutdown
# approach is that mod_ssl sends the close notify alert but doesn't wait for
# the close notify alert from client. When you need a different shutdown
# approach you can use one of the following variables:
# o ssl-unclean-shutdown:
# This forces an unclean shutdown when the connection is closed, i.e. no
# SSL close notify alert is send or allowed to received. This violates
# the SSL/TLS standard but is needed for some brain-dead browsers. Use
# this when you receive I/O errors because of the standard approach where
# mod_ssl sends the close notify alert.
# o ssl-accurate-shutdown:
# This forces an accurate shutdown when the connection is closed, i.e. a
# SSL close notify alert is send and mod_ssl waits for the close notify
# alert of the client. This is 100% SSL/TLS standard compliant, but in
# practice often causes hanging connections with brain-dead browsers. Use
# this only for browsers where you know that their SSL implementation
# works correctly.
# Notice: Most problems of broken clients are also related to the HTTP
# keep-alive facility, so you usually additionally want to disable
# keep-alive for those clients, too. Use variable "nokeepalive" for this.
# Similarly, one has to force some clients to use HTTP/1.0 to workaround
# their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
# "force-response-1.0" for this.
#BrowserMatch ".*MSIE.*" \
# nokeepalive ssl-unclean-shutdown \
# downgrade-1.0 force-response-1.0
</VirtualHost>
</IfModule>
Also the browser console lists the following errors multiple times:
Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING
Failed to load resource: net::ERR_EMPTY_RESPONSE
Any idea what I should do?
EDIT:
I forgot to mention that the behaviour is only present on Chrome browser. Firefox renders it properly and there are no errors in Firebug.
change the permision of this file ..
comand is ==>
sudo chmod -R a+rw /var
and then = <img src="../img/y.png">
Can't see the front end of my wordpress localhost.
The process I've done:
1. I installed wordpress locally with BitNami on Mac OX.
2. imported an existing data base to the phpmyadmin.
3. changed the wp-config file to support the local host database.
4. added these two lines
define('WP_HOME','http://localhost/wordpress');
define('WP_SITEURL','http://localhost/wordpress');
5. logged in to my wp-admin.
Now I can see the site's WP-ADMIN and do things in it BUT I cannot view the front end.
whenever I try i get:
can't establish a connection to the server at 127.0.0.1.
or if i try to view a post i get
"The requested URL /site/2013/02/13/idho_global/ was not found on this server."
If I'm trying to preview a draft I see it the way it should appear.
any help?
Check the database via phpmydmin and change the url if you didn't do it.
In the wp_options check if siteurl & home are set to localhost
Update : you should have a look to the 'Moving Wordpress page' https://codex.wordpress.org/Moving_WordPress
It explains very well ho to change permalinks and things to do after moving a Wordpress.
If your permalinks don't works, check if you have a .htaccess in the root directory. The content should be :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
You need to update the database urls. Wordpress hardcodes them. Run the sql below replacing "old-url.com/wordpress" and "new-url.com/wordpress" with your urls
UPDATE wp_posts SET guid = REPLACE(guid, 'old-url.com/wordpress', 'new-url.com/wordpress');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'old-url.com/wordpress', 'new-url.com/wordpress');
UPDATE wp_options SET option_value = REPLACE(option_value, 'old-url.com/wordpress', 'new-url.com/wordpress');
The most succinct way of summarizing the problem at hand:
Development is over, and everything was run against frontend_dev.php during development and testing
This means that all URLs were: server.com/frontend_dev.php/module/action/parm
Moving to production means switching environments, and thusly using index.php instead
server.com/index.php/module/action/parm
Part of moving to production is using mod_rewrite under Apache2 to make the “index.php” part of the URL vanish, but still be functioning
server.com/module/action/parm is still routed against index.php
The URLs are indeed appearing w/o the index.php part, but symfony routing is now complaining:
ie, server.com/goals which routes to goals/index
-- perfectly fine using frontend_dev.php or index.php as an explicit controller
server.com/index.php/goals
-- using no explicit controller (via rewrite):
[Tue Dec 14 12:59:51 2010] [error] [client 75.16.181.113] Empty module and/or action after parsing the URL "/goals/" (/)
I have verified the rewrite is indeed routing to index.php by changing the rewrite to something that doesn’t exist:
[Tue Dec 14 13:05:43 2010] [error] [client 75.16.181.113] script '/opt/www/projects/adam/web/index2.php' not found or unable to stat
I have tried rerouting to frontend_dev.php, but only am provided with more debug information from symfony, none of which is helpful:
404 | Not Found | sfError404Exception Empty module and/or action after parsing the URL "/goals/" (/).
stack trace
1. at () in SF_SYMFONY_LIB_DIR/controller/sfFrontWebController.class.php line 44 ...
2. at sfFrontWebController->dispatch() in SF_SYMFONY_LIB_DIR/util/sfContext.class.php line 170 ...
3. at sfContext->dispatch() in SF_ROOT_DIR/web/frontend_dev.php line 13 ...
I have tried the using the RewriteBase option in .htaccess, but that does not help any, nor changing the true/false in the configuration line of the controllers
I hope this provides enough to understand why we’re confused, and able to direct us to a resolution.
Following is the current .htaccess and index/frontend configuration lines
Index.php:
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);
Frontend_dev.php:
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'dev', true);
.htaccess:
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} ..+$
#RewriteCond %{REQUEST_URI} !.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
I had similar issue and setting 'AllowOverride' to ALL for Symfony's WEB folder in Virtual Host's config sorted out this problem.
Welcome to Stack Overflow.
Maybe you're confusing the "index" route with "index.php"?
These URLs should theoretically all work.
server.com/frontend_dev.php/goals/index
server.com/index.php/goals/index
server.com/goals/index
server.com/goals
I can't remember if the trailing slash, like server.com/goals/, works or not. There's a gotcha there.