htaccess to nginx converter - .htaccess

My htaccess code:
RewriteBase /mysite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (/[^.]*|\.)$ [NC]
RewriteRule .* index.php [L]
In nginx config I've tried this but it didn't work
location /mysite{
try_files $uri $uri/ /mysite/index.php$is_args$args;
}
Anyone can help me, tks so much.
p/s: I've tried http://www.anilcetin.com/convert-apache-htaccess-to-nginx/ and http://winginx.com/htaccess, but both of them can't help

Related

Htaccess rewrite localhost/website/index.php?pages=pages/login.php to localhost/website/login

I want to rewrite localhost/website/index.php?pages=pages/login.php to localhost/website/login
This was my attempt, when i open localhost/website/login it says 404 not found
RewriteEngine On
RewriteBase /Domain/
#Make sure it's an actual file
RewriteCond %{REQUEST_FILENAME} -f [OR]
#Make sure its a directory
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
#Rewrite the request to index.php
RewriteRule ^([^/]+)/?$ index.php?pages=pages/$1 [NC,L,QSA]
```
<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
RewriteBase /website/login
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?pages=pages/login.php [QSA,L]
</IfModule>
Hello, I don't know exactly what you want to do, but try this

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>

htaccess rewrite rule not happening

While having this structure:
domain.com
-index.php
frontend
.htaccess
index.php
account
-index.php
in my .htaccess :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?values=$1 [L]
</IfModule>
When i call :
http://domain.com/account
i get :
404 - Not Found
Anybody could help me why?
Greetings and thanks!

htaccess to nginx rules

I have a .htaccess file that I'm having trouble converting.
content of the .htaccess file:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and other folders,
RewriteCond $1 !^(index\.php|login|images|img|js|css|public|data|simplepie|application|system|cache)
RewriteRule ^(.*)$ index.php/$1 [L]
Nginx:
location / {
try_files $uri $uri/ index.php$is_args$args;
rewrite ^system.* index.php/$1 break;
if (!-e $request_filename){
rewrite !^(index\\.php|login|images|img|js|css|public|data|simplepie|application|system|cache) index.php/$1 break;
}
Any help will be appreciated.
Thanks

Codignier could not remove index.php on distant server

I'm using codeigniter. I removed index.php on localhost successfully but it's not working on distant server.
When I try to call: http://website.com/user/login it gives me [File not found]. But it works when i type: http://website.com/index.php/user/login
I put all files on www folder and this is my .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [PT,L]
Could anyone help me please?
Thanks.
This is the .htaccess I use:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Have you checked your .htaccess file is correct on the remote server and that it is being read?
This Works for me:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
And in your config.php:
$config['uri_protocol'] = 'AUTO';
This will remove index.php from both localhost and distant server.

Resources