I'm facing a problem with google's WebMasterConsole, some posts are indexed as follows url.com/index.php/posts/57 when the person enters, the site doesn't change anything but the adsense ads are not displayed, someone passed so is it google search problem or is it some htaccess rule? laravel 9 project.
I tried several solutions here from stackoverflow but none solved it on localhost so that I can implement it in production, does anyone have any idea what I might be doing to solve this issue?
Thanks in advance
My .htaccess file
<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]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Related
I'm writing a web application in laravel and have it almost working.
The only thing that is stopping me right now is the Rewrite Engine from apache ruining one particular route.
Route it should be: http://example.org/publicaties
Route it's
rewritten to: http://example.org/public
publicaties == publication but in dutch.
I'm using the following rewrite code as this is mostly the default for laravel if not completely:
DirectoryIndex index.php
<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]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Any help would be awesome!
Thanks
Solved
Turns out laravel doesn't like similar names like 'publicaties' and 'publications' because after changing the url, the issue was gone. Thanks all!
I'm starting to develop a new big app, and I'm using Laravel 8 this time, and it's the first time.
I trying to Redirect HTTP to HTTPS with .htaccess file but unfortunately it's not working https://app.workfromhere.com.my/ please help me thanks.
.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
# 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]
</IfModule>
I found out you are using cPanel, you can set Force HTTPS Redirect in Domains tap.
I realised that my site is not redirecting correctly when the URL link to a file (a pdf in this case). The others urls of my site are working perfectly. This is my htaccess file:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Force SSL
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
It's strange because after differents ways of typing my url I found this:
If I type "myweb.com/urltopdf", it is redirected to "https://myweb.com/urltopdf"
If I type "https://myweb.com/urltopdf", URL works
If I type "http://myweb.com/urltopdf", it isn't redirected and the url doesn't work. This case is my problem.
I dont know if it's important but I am using laravel 5.2.
Thanks.
EDIT: It works on firefox and edge but not on chrome.
so i am using cloudways with digitalocean and now trying to add letsencrypt into my laravel 5.4 web app...
and according to tech support in cloudways they say i need to modify my .htaccess to be like this
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
<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>
but after that i got
ERR_TOO_MANY_REDIRECTS
what's gone wrong? cloudways tech support can't give any solution either... so i kinda stuck in here
i also do some research before and read that i need to add
If(env(' APP_ENV') !== 'local') { $url->forceSchema('https'); }
into app/Providers/AppServiceProvider.php in boot function to make all request to be https....
but still no luck...
okay so i already got the solution, i forgot that my site also have cloudflare cdn and in crypto part it set SSL to Full mode, just change it to flexible one and everything works great....
Even /home is 404. I just start learning laravel, I don't know if I did something wrong.
After reinstall composer and created a new project the problem still
exist.
Xampp is running.
Here is the .htaccess in public:
<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>
have you added Route::get(/home, HomeController#index); to your routes file?