Please help, I've read a lot of posts about this issue, nothing helps.
I have yii2 installation under: c:/sites/mysite
The index.php file is in: c:/sites/mysite/web
I have htaccess file under c:/sites/mysite that looks like this:
# turn on rewrite engine
RewriteEngine on
RewriteBase /
RewriteRule ^index.html?$ home.php [NC,R,L]
DirectoryIndex home.php
# on what should it skip the rules
RewriteRule ^(favicon.ico) - [L]
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Do not allow calls from servers testing ou server fi were a proxy
# http://serverfault.com/questions/499125/banning-all-azenv-php-request-to-my-server
#RewriteCond %{HTTP_REFERER} .*/azenv\.php [NC,OR]
#RewriteRule .* - [F]
#RewriteCond %{HTTP:X-Forwarded-Proto} !https
#RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI}
# otherwise forward it to index.php
RewriteRule . index.php
I have my-vhosts file that has this code:
ServerName armanager
ServerAlias armanager
DocumentRoot "c:/sites/armanager/web"
Options Indexes FollowSymLinks
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
Going to mysite on firefox works fine.
I have a controller esController with actionSettings function.
I have a view settings.php
Going to mysite/es/settings gives me the dreaded 404 Not Found error.
Can you please help?
Ok, I added this .htaccess in the web folder:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</IfModule>
Now, everything works.
Related
I am using CodeIgniter 4.1.3.
below is my .htaccess
#Options All -Indexes
<IfModule mod_rewrite.c>
#Options +FollowSymlinks
RewriteEngine On
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
ServerSignature Off
options all and followSymlinks not supported on server.
Working fine on localserver
Front page is loaded but it is not loading css,javascript and image from public directory giving 404 error.
not sure what need to be change.
With your shown samples, please try following htaccess Rules file. Make sure to place this in your root directory. Also make sure to clear your browser cache before testing your URLs.
Options -Multiviews
<IfModule mod_rewrite.c>
#Options +FollowSymlinks
RewriteEngine On
RewriteBase /public/
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.php/$1 [L,NC,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
ServerSignature Off
JS/CS rewrite/redirect: You may need to use base tag to fix your js and other relative resources. If you are linking js files using a relative path then the file will obviously get a 404 because its looking for URL path. for example if the URL path is /file/ instead of file.html then your relative resources are loading from /file/ which is not a directory but rewritten html file. To fix this make your links absolute or use base tag. In the header of your webpage add this <base href="/"> so that your relative links can load from the correct location.
Options All -Indexes
Options +FollowSymlinks
works well on apache but if your server is centos then use this
Options -Indexes
Options +SymLinksIfOwnerMatch
I want to redirect to my contoller - SiteController.php and action actionLanguage. I think my htaccess is OK but can't reach the action. Everything that I am trying to put in the url leads me to admin/site/index and not to admin/site/language in my particular case. My .htaccess :
# prevent directory listings
Options -Indexes
# follow symbolic links
Options FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/admin/gii/?$
RewriteRule . backend/web/index.php?r=gii [L]
RewriteCond %{REQUEST_URI} ^/admin
RewriteRule ^admin(/.+)?$ /backend/web/$1 [L,PT]
RewriteCond %{REQUEST_URI} ^.*$
RewriteRule ^(.*)$ /frontend/web/$1
This line RewriteRule ^admin(/.+)?$ /backend/web/$1 [L,PT] must execute to backend/web/site/language when I type www.website.com/admin/site/languageright ? Or I am in some mistake? It redirects the request to the admin/site/index now. Appreciate every advice! Thank you in advance!
EDIT:
Backend .htaccess:
AddDefaultCharset utf-8
Options FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
RewriteRule ^static - [L]
My server structure is:
folder/
..
..
publicl_html/ ( Hehe is my project )
..
..
In public_html is my corporative site and there is also a folder which name is store. In this folder is the e-commerce part. The domain for this folder should be mysite.com/store/. I have a .htaccess file in the corporative part which redirects to the store prat :
#AddDefaultCharset utf-8
#Options +FollowSymLinks
#IndexIgnore */*
#RewriteEngine on
# Make the backend accessible via url: http://site/admin
#RewriteRule ^admin$ $admin.php [L]
# if a directory or a file exists, use it directly
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
#RewriteRule . index.php
#RewriteRule ^static - [L]
# prevent directory listings
#Options -Indexes
# follow symbolic links
#Options FollowSymlinks
RewriteEngine on
RewriteRule ^(store)($|/) - [L]
RewriteCond %{REQUEST_URI} ^/admin/$
RewriteRule ^(admin)/$ /$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/admin
RewriteRule ^admin(/.+)?$ /backend/web/$1 [L,PT]
RewriteCond %{REQUEST_URI} ^.*$
RewriteRule ^(.*)$ /frontend/web/$1
This line RewriteRule ^(store)($|/) - [L]. It is redirecting because i test it with just an index.php before uploading the whole project. But now i got 404error again ( the error page from the corporative site mysite.com).
This is the .htaccess in the public_html/store/ ( mysite.com/store/ ) folder :
#AddDefaultCharset utf-8
#Options +FollowSymLinks
#IndexIgnore */*
#RewriteEngine on
# Make the backend accessible via url: http://site/admin
#RewriteRule ^admin$ $admin.php [L]
# if a directory or a file exists, use it directly
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
#RewriteRule . index.php
#RewriteRule ^static - [L]
# prevent directory listings
Options -Indexes
# follow symbolic links
Options FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/admin/$
RewriteRule ^(admin)/$ /$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/admin
RewriteRule ^admin(/.+)?$ /backend/web/$1 [L,PT]
RewriteCond %{REQUEST_URI} ^.*$
RewriteRule ^(.*)$ /frontend/web/$1
Guess the problem is in the second .htaccess but i am not familiar with those redirects and seems that I will not handle it without your help. Thank you in advance!
I have copied a site down from live (works fine) on to my local machine. Locally I can view my homepage of the site, however if I then try and visit another page I keep getting 404's.
here is my vhosts setup:
<VirtualHost *:80>
DocumentRoot "C:\Users\Sony\Documents\websites\website.com"
ServerName local.website.com
<Directory "C:\Users\Sony\Documents\websites\website.com">
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
Anyone have an idea why this could be happening? Seems to only happen with the latest version of xampp and on urls that have been rewritten.
In case you are interested here is my htaccess file:
ErrorDocument 404 /404.php
RewriteEngine on
RewriteBase /
# remove www from host
RewriteCond %{HTTP_HOST} ^www\.(.+)
RewriteCond %{HTTPS}s/%1 ^(on(s)|offs)/(.+)
RewriteRule ^ http%2://%3%{REQUEST_URI} [L,R=301]
# remove trailing slash
RewriteRule ^(.*)\/(\?.*)?$ $1$2 [R=301,L]
# Don't match real existing files so CSS, scripts, images aren't rewritten
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Match the first two groups before / and send them to the query string
RewriteRule ^([+A-Za-z0-9-\.]+)?$ deals.php?country_code=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([+A-Za-z0-9-\.]+)/([+A-Za-z0-9-\.]+)?$ deals.php?country_code=$1&zone_id=$2 [L]
Any help would be appreciated
So I've just upgraded to Laravel 4, and I'm setting things up on a new server. The default / route works fine, but every other route returns a 404 error. When trying index.php/route, I get the requested data, so that means that .htaccess isn't working.
Yes, AllowOverride is set to ALL.
Yes, I enabled the mod_rewrite module.
I have tried the following 3 .htaccess combinations:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
and:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
and:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
And, after a server restart, and so on, none of them are working, and I'm still returning a 404 error.
Note: I am using several domains with the same laravel install, so my public folders are public/site1, public/site2, public/site3. However, I am routing the public paths to these folders, so I'm not sure that would be the problem.
Any thoughts?
I forgot to edit the vhosts in httpd.conf. Derp, derp.
Added:
<Directory "/var/www/public/site1">
AllowOverride All
</Directory>
to each of the site's vhost files, and it worked beautifully. Derp derp.