How can I add index.php hiddenly on laravel? - php

When I visit
--> website.com
its working fine.
But when I visit
--> website.com/page
its not working
Note that, If I visit
-->website.com/index.php/page its working fine.
So I want to add index.php in all pages but hiddenly. Because I don't want to see index.php in the pages.
here is my htaccess --->
Options -MultiViews -Indexes
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]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
<Files .env>
Order allow,deny
Deny from all
</Files>

Related

php script won't run correctly in subdirectory coz of .htaccess

I can't run php script in subdirectory and i believe there's something wrong with .htaccess file.
my subfolder name is "crm".
and here's .htaccess code:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# option to force redirect to ssl (https) - uncomment the two lines below
# RewriteCond %{HTTPS} !=on
# RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# 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_URI} !(\.css|\.js|\.svg|\.png|\.jpg|\.gif|robots\.txt|\.png|\.ttf|\.woff)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Can you please help me to fix this?
And when I try to get an image address from the subdirectory it thinks the image is on the root

How to host two websites 1st on domain root and 2nd on sub-directory

I have two websites, web-1 and web-2.
web1 is a HTML website and it's on the root domain which is domain.com
web-2 is a PHP app and it's on a sub-directory which is domain.com/web-2
web-1 is working normal but web-2 is not loading the website in full.
Here is my .htaccess file located in web-2
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# option to force redirect to ssl (https) - uncomment the two lines below
# RewriteCond %{HTTPS} !=on
# RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# 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_URI} !(\.css|\.js|\.svg|\.png|\.jpg|\.gif|robots\.txt|\.png|\.ttf|\.woff)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

How to redirect old website to a new one, but access the assets from the old site with .htaccess?

I hava a old site, example.com. What i need to do is redirect it to new website example.com.np. But the new website points to files of the old website, example.com. Is there a way I can redirect example.com to example.com.np, but access the assets from the old website?
My .htaccess for example.com is
<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>

all pages redirecting too many time except home page (laravel)

i have laravel webstie my web home page is working only all other pages redirecting too many times even it die; in the start of app/public/index.php
not stopping .
my myroot/public/.htaccess code is below
<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 ^(.*)$ http://self.phpavenue.com/$1 [R=301,L]
</IfModule>
please check the access code and help me
thanks
try replacing RewriteRule ^ %1 [L,R=301] with following
RewriteRule ^ index.php [L]

.htaccess file issue while redirecting from index.php to normal link when on home page

I am working on a LARAVEL 5.3 application and trying to redirect all requests with index.php to without index.php
e.g.: if someone enters example.com/index.php/some-uri-segments,
it should redirect to example.com/some-uri-segments.
I have successfully achieved this with following code:
<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]
#index.php to normal
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^index.php(.*)$ $1 [R=301,L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
But there is a problem when the link is example.com/index.php.
The request with example.com/index.php is redirected to example.com/var/www/html/public
But I want it to be redirected to only example.com.
You are missing a / in your code. Try this one:
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^index.php(.*)$ /$1 [R=301,L]

Categories