Can someone help me to rewrite this line from htaccess file to Nginx
RewriteRule ^([\w]+)\.api(/(.*))?$ site.php?action=api_$1&arg=$3 [QSA,L]
Try it in you location. Eg:
location / {
....
rewrite ^/([\w]+)\.api(/(.*))?$ /site.php?action=api_$1&arg=$3 break;
....
}
Related
I'm trying to convert the following NGINX rule:
location = /js/index.php/x.js { rewrite ^(.*.php)/ $1 last; }
to .htaccess. I tried:
RewriteRule ^/js/index.php/x.js ^.*\.php
but it isn't working.
Try with:
RewriteRule ^(js/index\.php)/x\.js $1
can anybody help me to convert .htacess file to nginx rewrite rule
my htaccess blew
RewriteEngine On
RewriteRule ^video/([^/]*)/([^/]*)\/$ /index.php?page=details&title=$1&id=$2 [L]
RewriteRule ^video/([^/]*)\.html$ /index.php?page=result&q=$1 [L]
i try apply on here:
/etc/nginx/sites-available/default
# nginx configuration
location /video {
rewrite ^/video/([^/]*)/([^/]*)\/$ /index.php?page=details&title=$1&id=$2 break;
rewrite ^/video/([^/]*)\.html$ /index.php?page=result&q=$1 break;
}
not working..
I have moved site from apache to nginx and I have got some issue with nginx.
htaccess
RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(js|css|png|jpg|jpeg|bmp|ttf|php|php5|html|htm|gif)$
RewriteRule ^(.+)/(.+[^/])/(.*[^/])/?$ index.php?p=$1&subp=$2&subsubp=$3 [QSA,L]
RewriteCond %{REQUEST_URI} !\.(js|css|png|jpg|jpeg|bmp|ttf|php|php5|html|htm|gif)$
RewriteRule ^(.+)/(.+[^/])/?$ index.php?p=$1&subp=$2 [QSA,L]
RewriteCond %{REQUEST_URI} !\.(js|css|png|jpg|jpeg|bmp|ttf|php|php5|html|htm|gif)$
RewriteRule ^(.*[^/])/?$ index.php?p=$1 [QSA,L]
Options -Indexes
And using converter to nginx:
location ~ \.(js|css|png|jpg|jpeg|bmp|ttf|php|php5|html|htm|gif)$ {
}
location ~ \.(js|css|png|jpg|jpeg|bmp|ttf|php|php5|html|htm|gif)$ {
}
location ~ \.(js|css|png|jpg|jpeg|bmp|ttf|php|php5|html|htm|gif)$ {
}
autoindex off;
location / {
rewrite ^/(.+)/(.+[^/])/(.*[^/])/?$ /index.php?p=$1&subp=$2&subsubp=$3 break;
rewrite ^/(.+)/(.+[^/])/?$ /index.php?p=$1&subp=$2 break;
rewrite ^/(.*[^/])/?$ /index.php?p=$1 break;
}
I think that, can work when we are not talking about subdomain.
Yes - my site is in subdomain called /mysub/
So to enter my website I use mysub.domain.com or domain.com/mysub/
(where the first is this:)
if ($http_host = "mysub.domain.com") {
rewrite ^(?!/\b(mysub|stats|error)\b)/(.*)$ /mysub/$2 ;
}
Question:
How to link these rules into one ?
I Got this URL
http://localhost/test/test.php/1
This is I want to
http://localhost/test/test.php?a=1
test.php
echo $_GET['a'];
How to write .htaccess rule for it?
RewriteEngine On
RewriteRule ^test/test\.php/(\d+)$ /test/test.php?a=$1 [L]
Put this in htaccess file and place it in the document root directory of apache.
Asking for your help:
I want to write a htaccess rewrite rule that will redirect all urls :
accounts.mysubdomain.com/TB/.... -->
accounts.mysubdomain.com/....
can you please help me out?
TIA
Create a .htaccess file in /TB/ directory to redirect to any directory (you can have absolute or relative paths instead of my_dir)
RewriteEngine On
RewriteRule ^TB/(.*)$ /new_dir/$1 [R=301,L]
If you are redirecting everything in the accounts.mysubdomain.com/TB/ to accounts.mysubdomain.com then use the following rule:
RewriteEngine On
RewriteRule ^TB/(.*)$ http://accounts.mysubdomain.com/$1 [R=301,L]