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

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>

Related

Laravel throwing 404 on images/css/js

Laravel is throwing a 404 error on my images, css and javascript files which are located in /mysite/public. I've set /mysite/public as the site's root folder and all my assets are located in there.
I did a google search on this error but they all gave the same solution i.e {{asset('css/style.css')}}. I already have my links setup like this so I don't think this is the problem.
I think the error has something to do with my Rewrite rules but I just can't figure our what it is.
My site's .htaccess file is:
RewriteEngine On
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.my-site.com/$1 [R,L]
</IfModule>
If I delete the first RewriteRule, my css loads fine but pages other that the homepage will start throwing a 404 error. If I put it back, other page work fine but css, js and image file stop loadings.
Your first rule essentially says "regardless of what the URL is, load index.php". This means it will never load your assets, which are physical folders, as it will just load index.php instead. For example, if you tried to load css/image.png it will just load index.php.
If you remove it, your actual folders will load, but other URLs aren't re-written to index.php, which is why it will break.
You should use the .htaccess provided to you by Laravel. This should be your .htaccess file in the public/ folder (as per the Laravel Github repository)
<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}]
</IfModule>
public/.htaccess
If the public folder is not the root on your server, you'll also need to have this in an additional .htaccess (in the folder above public)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
/.htaccess
add this rule to keep assets from being routed to the router
RewriteEngine On
# Don't rewrite for css/js/img assets
RewriteRule ^assets/.* - [L]
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.my-site.com/$1 [R,L]

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>

Redirect existing URL to a new scheme .htaccess

NOTE: In the beginning we were redirecting https://domain.com/stats.php?player=name to https://domain.com/p/name (so some of the answers may pertain to that), but now I am redirecting to https://domain.com/#name
There is still one unresolved issue though. I wish to make https://domain.com/stats.php?player=name automatically redirect to https://domain.com/#name when visited.
<IfModule mod_rewrite.c>
ErrorDocument 404 /404.php
RewriteRule ^#(\w+)$ stats.php?player=$1
Options +FollowSymlinks
Options -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
</ifModule>
create a .htaccess file or use apache rewrite: http://httpd.apache.org/docs/current/mod/mod_rewrite.html
The rule is :
RewriteEngine On
RewriteRule ^p/(\w+)$ stats.php?player=$1

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.

htaccess not working on my VPS with cpanel

I have a website which was on a VPS with directadmin Control Panel, but I have just moved to another VPS with Cpanel. It used to work when it wan on the old VPS but in the new one I can’t make it work..!!
My script is CodeIgniter script and in this script this url:
www.mydomain.com/index.php/news
should be converted to:
www.mydomain.com/news
But after using htaccess, I can open the main page (which is index.php) greatly but when I want to go to www.mydomain.com/news (this should be defined as www.mydomain.com/index.php/news by htacces ) it shows me the main page. I have installed CodeIgniter (the framework I am using for my script) in the public_html folder (which is under home/user).
I have full admin access to my VPS, WHM/Cpanel and I can make any changes.
this is the .htaccess that was working for me in my old VPS:
Options FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
I have just found that by converting this line:
RewriteRule ^(.*)$ index.php/$1 [L]
to this one:
RewriteRule ^(.*)$ index.php/$1 [R]
means changing flag [L] to [R], it works, but it just converts www.domain.com/news to www.domain.com/index.php/news and shows in the addressbar and this not what I want.
Do you have any solution?! Should I change any configuration on Cpanel?!
Try this one:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond $1 !^(index\.php|images|css|js|favicon\.ico|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
Hope it works on your CodeIgniter install, I had the same problem and this solved it.

Resources