getting problem in .htaccess file 403 error - .htaccess

i have file .htaccess
here is the sources of .htaccess
<IfModule mod_rewrite.c>
Header set Access-Control-Allow-Origin "*"
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$2/?page=$1
[L]
</IfModule>
and when i open localhost it error of 403 FORBIDDEN
You don't have permission to access /index.php on this server.
how i fix ?

when I remove this one line
Header set Access-Control-Allow-Origin "*"
the problem was solve

Related

CSS & JS file not loading in my cakphp appliaction

I have a cakephp website hosted on goDaddy, the css and js file are showing 404 error and the page appears blank.
i have done changes to .htaccess file in both webroot and main directory
.htaccess file in www directory
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(\.well-known/.*)$ $1 [L]
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
and .htaccess file in webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
i'm not sure what is the cause.I checked the error log and its shows this
2020-09-02 08:06:25 Error: [Cake\Routing\Exception\MissingControllerException] Controller class Webroot could not be found.
Request URL: /webroot/
Try using this on the /webroot .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

htaccess 301 redirect DIrectory show file on file

I help how setting my htaccess if i want
redirect if youser visit directory
example.com/data/ need redirect on example.com/404
if user visit file
example.com/data/myfile.pdf show the file or download
Have this rule inside /data/.htaccess:
RewriteEngine On
RewriteOptions inherit
RewriteRule ^/?$ /404 [L,NC,R=301]
that my final configuration and work great
ErrorDocument 404 /index.php
ErrorDocument 403 /error/403
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]
</IfModule>

CodeIgniter: Remove index.php redirects to the wrong folder

I tried all solutions I found about removing index.php from the URL, but I still cannot make it work properly.
Problem:
the URL http://localhost/rc/index.php/person/find shows the correct page.
the URL http://localhost/rc/person/find shows the WAMP main page (without any image) like it redirects to the root's parent folder.
my configuration:
I created .htaccess is placed in my root directory (/www/rc/.htaccess) which contains the following code:
<IfModule mod_rewrite.c>
# Turn on MOD REWRITE engine
RewriteEngine On
#Remove index.php from the URL
RewriteBase /rc/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#Also tried the following lines without success
#RewriteRule .* index.php/$0 [PT,L]
#RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
# If mod_rewrite is not installed, fire 404 error
ErrorDocument 404 /index.php
</IfModule>
I have also set $config['index_page'] = ''; (in www/rc/application/config/config.php file).
You must put your rule before CodeIgniter's main rule.
Replace your current code by this one (your htaccess has to be in rc folder)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /rc/
RewriteCond %{THE_REQUEST} \s/rc/index\.php/([^\s]+) [NC]
RewriteRule . %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
The answer was given by Justin Iurman in the comment of the first answer:
Are you sure mod_rewrite is enabled ? You can check it in your apache config
This can be enabled in httpd.conf file or from the WAMP tray icon.

https url require index.php in the url. How to fix this?

we have a magento website www.oursite.in, when i use http://www.oursite.in/mobiles.html, it works fine (i.e. index.php isn't required / doesn't appear in the url).
but when I type https://www.oursite.in/mobiles.html, it says 404 not found error https://www.oursite.in/index.php/mobiles.html works fine.
how do i rewrite url for https url in .htaccess?
or
is there any other configuration changes in magento?
can somebody throw some light on this for me?
link below explaining htaccess for https, though it is for codeigniter developer but it will work for magento to..
http://ellislab.com/forums/viewthread/86113/
RewriteRule ^(.*)$ index.php/$1 //this line will hide index.php from url
<IfModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymLinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

moved to dedicated virtual server, having trouble with .htaccess and permissions

Working with cakePHP
My index.php is in www.domain.com/httpdocs/sub/app/webroot
Previously, on shared hosting I just replaced "domain.com/" with "domain.com/app+core directories" (without httpdocs/ or sub/)
I've moved to media temple dedicated virtual server and am hitting a 403 forbidden error:
"You don't have permission to access /sub/ on this server."
Permission is set to 755 for sub/ directory
In domain.com/sub/app -> .htaccess file:
Code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /sub/app/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
In domain.com/sub/app/webroot -> .htaccess file:
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteBase /sub/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
I've tried:
Right now httpdocs/ contains blank index.html and simple redirect:
Redirect /index.html http://domain.com/sub/
Creating another .htaccess file for /sub, but that seemed to confound things further.
I'm on media temple, followed this article: http://wiki.mediatemple.net/w/403_Forbidden_error
Thanks
Noticed you were having some issues with your (dv). We just wanted to let you know that we are here to help you with any problems that you may have. If you keep running into these errors, please open up a Support Request so we can help you out.

Resources