Why may Laravel route() redirect to http://localhostarticle instead http://localhost/article
blog.conf
DocumentRoot /var/www/blog/public
ErrorLog ${APACHE_LOG_DIR}/blog/error.log
CustomLog ${APACHE_LOG_DIR}/blog/access.log combined
<Directory "/var/www/blog/public">
Options Indexes MultiViews FollowSymlinks
AllowOverride All
Order allow,deny
Allow from All
</Directory>
.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_URI} !^
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Send requests to public directory...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
Remove all redirects from apache vhost and its helped
Related
My domain requests are redirecting to the root of the domain instead of the given file type when attempting to redirect non www to www.
For example; I want website ---.com/dogs to go to www.---.com/dogs but instead it goes to www.---.com.
I'm using Laravel. What could be wrong?
My htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
#rewrite
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# 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]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Virtual Host:
<VirtualHost 1.1.1.1:443>
SSLEngine on
SSLCertificateFile /root/sslcert/--.pem
SSLCertificateKeyFile /root/sslcert/--.key
ServerName www.--.com
#ServerAlias --.com
DocumentRoot "/var/www/website-live/public"
<Directory /var/www/website-live/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I've tried removing the conditions i added for the redirect and no redirect occurs, so only with the two lines under #rewrite do these issues occur
Hello so i got back to laravel recently and want to put on my webserver but i get error 500 from a fresh installed laravel. though i havent done any modifying the code in the framework would be sweet if anyone has an idea whats going on in the changes to laravel from those settings i provide
error 500 and no logs in apache nor laravel
thanks in advance
htaccess file.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
conf file
ServerName domain.com
DocumentRoot /var/www/laravel/public/
<Directory /var/www/laravel/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
If you're using Linux os,you'll need to do the following
cd to_the_root_of_project - i.e. cd /var/www/html/LaravelProject
sudo chmod guo+w -R storage/
Is there a specific RewriteRule that would work for Magento and convert
http://<domainname>/index.php/<filename>
into
http://<domainname>/<filename>
According to phpinfo(), Loaded Modules lists mod_rewrite , so it appears to be enabled.
Here is the relevant section from .htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
</IfModule>
Any suggestions?
So it turns out that it wasn't a missing mod_rewrite rule. I fixed it by inserting the Directory section below into /etc/apache2/sites-available/dev.magecom.local.conf (The Directory section didn't exist at all in the previous version).
<VirtualHost *:80>
ServerName dev.magecom.local
ServerAlias www.dev.magecom.local
DocumentRoot /var/www/sites/dev.magecom.local/public_html/
<Directory /var/www/sites/dev.magecom.local/public_html/>
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I have a CakePHP 2.x app here: /Users/cameron/Sites/ExampleApplication
And inside it has the standard structure:
/app
/webroot
etc.
However when I go to:
localhost/~cameron/ExampleApplication
I get the error: The requested URL /Users/cameron/Sites/ExampleApplication/app/webroot/ was not found on this server.
However if I setup a VirtualHost like:
<Directory "/Users/cameron/Sites">
Header set Access-Control-Allow-Origin "*"
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
DocumentRoot "/Users/cameron/Sites/ExampleApplication"
ServerName example.com
UseCanonicalName Off
</VirtualHost>
It works fine!
Any ideas why it works for the VirtualHost but NOT when accessing it via the usual localhost?
Here is what is inside the three .htaccess files:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
If you use Mamp, you have to configure the htaccess file
and modify htaccess in folder root / app/webroot and app/config
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase / "production" or /nameFolder/ "dev"
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
I'm very new to apache. I read and read docs, turn all conf files I found, but ...
While I'm root on the webserver, I read that in order to optimize apache2, it is not a good idea to use .htaccess files (http://httpd.apache.org/docs/current/howto/htaccess.html).
OK, I read a lot of howtos about url_rewriting and htacess. I tried this code into my www.site.com virtualhost file :
<VirtualHost *:80>
ServerName site.com
ServerAlias www.site.com
ServerAdmin webmaster#site.com
DocumentRoot /var/www/www.site.com
RewriteEngine On
<directory />
RewriteBase /var/www/www.site.com/
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Please note that RewriteBase has been tested with DocumentRoot value and '/', and that all the RewriteCond come form std_htaccess of latest Joomla! source code.
Apache2 launches well, the site is viewed online with no error, but the rewrite is not working as joomla SEF is not working :(
I'm totaly lost ... again ... and I need your help guys !
Ok, the correct way is
<directory /var/www/www.site.com/>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
Options FollowSymLinks
AllowOverride None
</Directory>