HTACCESS repeats url twice - .htaccess

Hi Am having this little problem with .HTACCESS HTTPS redirection
Not Found
The requested URL /limoamerican/limoamerican/limofleet.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Any help is appreciated
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Options -Multiviews
Options +FollowSymLinks
#LoadModule rewrite_module modules/mod_rewrite.so
#AddModule mod_rewrite.c
RewriteBase /
#RewriteRule ^geo/United-States/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ ijt.php?state=$1&city=$2 [NC,L]
#RewriteRule ^geo/United-States/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ rxm.php?state=$1&city=$2 [NC,L]
RewriteRule ^geo/United-States/NY/([A-Za-z0-9-]+)/?$ mxt.php?city=$1 [NC,L]
RewriteRule ^geo/United-States/CT/([A-Za-z0-9-]+)/?$ ijt.php?city=$1 [NC,L]
RewriteRule ^geo/United-States/NJ/([A-Za-z0-9-]+)/?$ rxm.php?city=$1 [NC,L]

Related

htaccess /en works normal but /en/ gives page cannot be found

when browsing www.mywebsite.com/en or www.mywebsite.com/fr it works fine, if browsing with / at the end of any, it gives page cannot be found
i'm using the htaccess code below:
RewriteOptions inherit
RewriteEngine on
AddDefaultCharset UTF-8
Options -Indexes
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^fr$ index.php
RewriteRule ^en$ index_en.php
RewriteRule ^fr/(.*)$ $1.php
RewriteRule ^en/(.*)$ $1_en.php
Try replacing
RewriteRule ^fr$ index.php
RewriteRule ^en$ index_en.php
With
RewriteRule ^fr/?$ index.php
RewriteRule ^en/?$ index_en.php

What is the code to be added to Redirect from http to https in .htaccess file?

What is the code to be added to Redirect from http to https in .htaccess file?
here is the existing code in .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/NextNext/
RewriteRule ^(.*)$ /public/$1 [L]
</IfModule>
awaiting your help..
Try this rule after RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Friendly URL's returns 404

Hello everyone.
I have a problem with my htaccess file. I made friendly url's but server returns 404 error and i can't find where i made mistake in code. I spent 3 hours on it and still nothing. I'm begging you for help guys :D
Here's my code:
Options -Indexes
DirectoryIndex index.php
RewriteEngine On
RewriteBase /
RewriteRule ^([a-zA-Z0-9-_/]+)$ /$1.php [L,NC,QSA]
RewriteRule ^([a-zA-Z0-9-_/]+).(php|html|htm)$ /$1 [NC,R=301,L]
RewriteRule ^index.(php|html|htm)$ / [R=301,L]
Redirect is making good but server returns 404 error instead display website.
I want to make urls like example below:
From:
www.domain.com/customers.php
www.domain.com/products/number1.php
To:
www.domain.com/customers
www.domain.com/products/number1
Ok i solved this but now i have a redirect loop :(
New code:
Options -Indexes
DirectoryIndex index.php
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L]
RewriteRule ^([a-zA-Z0-9-_/]+).(php|html|htm)$ /$1 [NC,R=301,L]
RewriteRule ^index.(php|html|htm)$ / [R=301,L]
Try this
RewriteOptions inherit
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

XCart 1.19.2.1 - enabling SSL

Can someone help me with this one please?
We have a XCart site running version 1.19.2.1 and we would like to force all traffic to HTTPS. The SSL certificate is installed and the .htaccess file looks like this:
DirectoryIndex home.php index.php index.html index.htm
# ErrorDocument 404 /404.php
# Show default error document for 404 errors caused by opening of image/media files.
<Files ~ "\.(gif|jpe?g|png|js|css|swf|ico)$">
ErrorDocument 404 default
ErrorDocument 401 default
# Clean URLs [[[
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(ww+\.)?domain\.com
RewriteRule ^(.*) http://www.domain.co.uk/$1 [R=301,L]
<IfModule mod_rewrite.c>
RewriteCond %{ENV:REDIRECT_STATUS} !^401$
RewriteCond %{REQUEST_URI} !^/(payment|admin|provider|partner)/
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpe?g|png|js|css|swf|php|ico)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ dispatcher.php [L]
</IfModule>
# /Clean URLs ]]]
RewriteEngine on
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php56” package as the default “PHP” programming language.
<IfModule mime_module>
AddType application/x-httpd-ea-php56 .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
I have tried editing the file to redirect all traffic to HTTPS, I get a too many redirects error.
One example that I tried was replacing the entire contents of the .htaccess file with:
ErrorDocument 404 /index.php
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
rewritecond %{http_host} ^domain.co.uk [nc]
rewriterule ^(.*)$ https://www.domain.co.uk/$1 [r=301,nc]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.domain.co.uk/$1 [R=301,L]
# RewriteRule ^([a-zA-Z0-9\-\%\s\_\.]+)(.htm)$ index.php?page=$1 [L]
##RewriteRule ^([a-zA-Z0-9\-\%\s\_\.]+)\.htm$ index.php?page=$1 [L]
DirectoryIndex index.php
#DirectoryIndex site_closed.html
RewriteEngine on
The above works fine on another XCart site but not this one. Again, I get the too many redirects error.
Anybody have any idea how I can fix it?
Kind regards
James
I had edited the htaccess file but I hadn't edited the https.php file as described here: https://help.x-cart.com/index.php?title=X-Cart:Configuring_HTTPS#Configure_the_HTTPS_server_in_X-Cart
All working now.

Trouble with .htaccess mod_rewrite

Please can somebody take a look at my .htaccess code to help identify what's wrong.
I am trying to amend all example.php, example.html and example.htm URL's to index.php?filename=example.html
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(index\.php) - [L]
RewriteRule ^([^/\.]+).(php|html|htm)$ index.php?filename=$1.html&%{QUERY_STRING} [L]
</IfModule>
When I enter a URL like example.html I'm taken to the default 404 and not index.php
Try:
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?filename=$1 [L,QSA]
</IfModule>
I'm not using the apache .hatacces for a while,
But try this one:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/index\.php$
RewriteCond %{REQUEST_URI} !^.*/(css|img|js)($|/.*$) [NC]
RewriteRule ^(.*)$ /index.php?filename=$1&%{QUERY_STRING} [L]
Basically what you need is to be sure that the URL didn't have already index.php. You accomplish it with RewriteCond.
After you redirect all to index.php passing the filename as a parameter.
You can add more exception to the RewriteCond like on this example, all content with /css, /js, /img will not pass to this rule.
You can check this thread: Using .htaccess to reroute all requests through index.php EXCEPT a certain set of requests also

Resources