I want to rewrite my yii application urls ,i just doen it and it works fine in my local machine . but when i move to server it is not working and shows a 500 Internal Server error
My current url is like this
cvdb.example.com/index.php/list/index
i want to rewrite it as
cvdb.example.com/list/index
Here is my code in config/main.php
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'caseSensitive'=>false,
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
And here is my .htaccess code
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
Here what i get when i put var_dumb($_SERVER)
array(39) {
["DOCUMENT_ROOT"]=>
string(29) "/home/bridge/public_html/cvdb"
["GATEWAY_INTERFACE"]=>
string(7) "CGI/1.1"
["HTTP_ACCEPT"]=>
string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
["HTTP_ACCEPT_LANGUAGE"]=>
string(14) "en-US,en;q=0.5"
["HTTP_CONNECTION"]=>
string(5) "close"
["HTTP_COOKIE"]=>
string(339) "fbm_1=base_domain=.cvdb.example.com; PHPSESSID=a6b697793d5abf01012435cf868a2f13; 52862fa7c29cebef614e5f38c01514c2=5571bdfdfdfdfdfdfb1ed61d4cae29f6145035a37a9d4ee45e83a%3A4%3A%7Bi%3A0%3Bs%3A1%3A%221%22%3Bi%3A1%3Bs%3A13%3A%22Administrator%22%3Bi%3A2%3Bi%3A31536000%3Bi%3A3%3Ba%3A1%3A%7Bs%3A4%3A%22role%22%3Bs%3A2%3A%2210%22%3B%7D%7D"
["HTTP_HOST"]=>
string(23) "cvdb.example.com"
["HTTP_USER_AGENT"]=>
string(72) "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0"
["HTTP_X_FORWARDED_FOR"]=>
string(14) "220.336.5.3"
["HTTP_X_FORWARDED_HOST"]=>
string(23) "cvdb.example.com"
["HTTP_X_FORWARDED_SERVER"]=>
string(23) "cvdb.example.com"
["HTTP_X_REAL_IP"]=>
string(14) "220.336.5.3"
["PATH"]=>
string(13) "/bin:/usr/bin"
["PHPRC"]=>
string(13) "/home/bridge/"
["QUERY_STRING"]=>
string(0) ""
["REDIRECT_PHPRC"]=>
string(13) "/home/bridge/"
["REDIRECT_STATUS"]=>
string(3) "200"
["REDIRECT_UNIQUE_ID"]=>
string(24) "UtTWkTIfkzwAAddfdFUWCbwAAAAD"
["REDIRECT_URL"]=>
string(11) "/list/index"
["REMOTE_ADDR"]=>
string(14) "220.227.90.185"
["REMOTE_PORT"]=>
string(5) "43681"
["REQUEST_METHOD"]=>
string(3) "GET"
["REQUEST_URI"]=>
string(11) "/list/index"
["SCRIPT_FILENAME"]=>
string(39) "/home/bridge/public_html/cvdb/index.php"
["SCRIPT_NAME"]=>
string(10) "/index.php"
["SERVER_ADDR"]=>
string(12) "50.31.147.60"
["SERVER_ADMIN"]=>
string(33) "webmaster#cvdb.example.com"
["SERVER_NAME"]=>
string(23) "cvdb.example.com"
["SERVER_PORT"]=>
string(2) "80"
["SERVER_PROTOCOL"]=>
string(8) "HTTP/1.0"
["SERVER_SIGNATURE"]=>
string(0) ""
["SERVER_SOFTWARE"]=>
string(156) "Apache/2.2.25 (Unix) mod_ssl/2.2.25 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_python/3.3.1 Python/2.4.3 mod_jk/1.2.37 mod_bwlimited/1.4 mod_perl/2.0.6 Perl/v5.8.8"
["UNIQUE_ID"]=>
string(24) "UtTWkTIfkzwAAFUWCbwAAAAD"
["ORIG_PATH_INFO"]=>
string(11) "/list/index"
["ORIG_PATH_TRANSLATED"]=>
string(39) "/home/bridge/public_html/cvdb/index.php"
["PHP_SELF"]=>
string(10) "/index.php"
["REQUEST_TIME"]=>
int(1389680273)
["argv"]=>
array(0) {
}
["argc"]=>
int(0)
}
try this
<ifModule mod_rewrite.c>
# Turn on the engine:
RewriteEngine on
# Don't perform redirects for files and directories that exist:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# For everything else, redirect to index.php:
RewriteRule . index.php
</ifModule>
Or just try removing this line simply from your .htaccess file
RewriteBase /
Related
How can I use .htacess to re-direct iphones, ipads, android phone and android tablets. each to a different link (4 links)
I have used some codes but they re-direct only phones and I am not really an expert in this
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge\ |maemo|midp|mmp|opera\ m(ob|in)i|palm(\ os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows\ (ce|phone)|xda|xiino [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a\ wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r\ |s\ )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1\ u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp(\ i|ip)|hs\-c|ht(c(\-|\ |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac(\ |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt(\ |\/)|klon|kpt\ |kwc\-|kyo(c|k)|le(no|xi)|lg(\ g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-|\ |o|v)|zz)|mt(50|p1|v\ )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v\ )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-|\ )|webc|whit|wi(g\ |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-) [NC]
RewriteRule ^$ https://website.com [R,L]
I believe that this configuration is what you need ...
if(isset($_SERVER["HTTP_USER_AGENT"])){
$userAgent = $_SERVER['HTTP_USER_AGENT'];
//code from http://detectmobilebrowsers.com/
if(preg_match(
'/(android|bb\d+|meego).+mobile|avantgo|bada\/
|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)
|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i
|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo
|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i',
$userAgent
)
||preg_match(
'/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac
|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)
|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)
|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell
|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob
|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8
|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)
|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)
|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k
|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)
|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)
|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)
|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))
|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks
|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)
|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)
|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc
|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',
substr($userAgent,0,4)
)
) {
$isMobile = true;
}
}
if ($isMobile && $_GET["redirect"] !== "off") {
header("Location: mobile/index.php");
} else {
header("Location: index.php");
}
Can someone explain me how can i rewrite this to make it work with php-fpm (vestacp)?
It's a CrowdPHP script. Atm we need to move to php-fpm server, but... seems it is impossible to make a proper nginx template for this. I've tried to use some online converters, but nothing works.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^project\/(.*)-id-([0-9]+)\.html$ index.php?ctl=deal&act=show&id=$2 [QSA,L]
RewriteRule ^project\/updates\/(.\d)\/$ index.php?ctl=deal&act=update&id=$1 [QSA,L]
RewriteRule ^project\/comments\/(.\d)\/$ index.php?ctl=deal&act=comment&id=$1 [QSA,L]
RewriteRule ^user\/(.\d)\/$ index.php?ctl=home&id=$1 [QSA,L]
RewriteRule ^user\/(.\d)\/funded\/$ index.php?ctl=home&act=support&id=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
#Custom Rerites
#RewriteRule ^projects-we-like.html$ index.php?ctl=article&id=77
RewriteRule ^article_cate$ index.php\?ctl=article_cate [QSA,L]
RewriteRule ^(about|Help|events|media|about-us|how-to)$ index.php\?ctl=article_cate&bs=$1 [QSA,L]
RewriteRule ^(about|Help|events|media|about-us|how-to)/([^\.&]*)\.html$ index.php\?ctl=article&id=$2 [QSA,L]
RewriteRule ^([^\.&]*)\.html$ index.php\?rewrite_param=$1 [QSA,L]
</IfModule>
Use this
# nginx configuration location /project { rewrite ^/project\/(.*)-id-([0-9]+)\.html$ /index.php?ctl=deal&act=show&id=$2 break; rewrite ^/project\/updates\/(.\d)\/$ /index.php?ctl=deal&act=update&id=$1 break; rewrite ^/project\/comments\/(.\d)\/$ /index.php?ctl=deal&act=comment&id=$1 break; } location /user { rewrite ^/user\/(.\d)\/$ /index.php?ctl=home&id=$1 break; rewrite ^/user\/(.\d)\/funded\/$ /index.php?ctl=home&act=support&id=$1 break; } location / { if (!-e $request_filename){ rewrite ^/article_cate$ /index.php\?ctl=article_cate break; } rewrite ^/([^\.&]*)\.html$ /index.php\?rewrite_param=$1 break; } location /about { rewrite ^/(about|Help|events|media|about-us|how-to)$ /index.php\?ctl=article_cate&bs=$1 break; rewrite ^/(about|Help|events|media|about-us|how-to)/([^\.&]*)\.html$ /index.php\?ctl=article&id=$2 break; } location /Help { rewrite ^/(about|Help|events|media|about-us|how-to)$ /index.php\?ctl=article_cate&bs=$1 break; rewrite ^/(about|Help|events|media|about-us|how-to)/([^\.&]*)\.html$ /index.php\?ctl=article&id=$2 break; } location /events { rewrite ^/(about|Help|events|media|about-us|how-to)$ /index.php\?ctl=article_cate&bs=$1 break; rewrite ^/(about|Help|events|media|about-us|how-to)/([^\.&]*)\.html$ /index.php\?ctl=article&id=$2 break; } location /media { rewrite ^/(about|Help|events|media|about-us|how-to)$ /index.php\?ctl=article_cate&bs=$1 break; rewrite ^/(about|Help|events|media|about-us|how-to)/([^\.&]*)\.html$ /index.php\?ctl=article&id=$2 break; } location /about-us { rewrite ^/(about|Help|events|media|about-us|how-to)$ /index.php\?ctl=article_cate&bs=$1 break; rewrite ^/(about|Help|events|media|about-us|how-to)/([^\.&]*)\.html$ /index.php\?ctl=article&id=$2 break; } location /how-to { rewrite ^/(about|Help|events|media|about-us|how-to)$ /index.php\?ctl=article_cate&bs=$1 break; rewrite ^/(about|Help|events|media|about-us|how-to)/([^\.&]*)\.html$ /index.php\?ctl=article&id=$2 break; }
Heroku is throwing repeated 302 redirects for all urls going to the base URL, and I don't know why. Everything works fine locally on my dev server.
Procfile:
web: fuel/vendor/bin/heroku-php-apache2 web/
.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymLinks -Indexes
# Remove index.php from URL
RewriteCond %{HTTP:X-Requested-With} !^XMLHttpRequest$
RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
RewriteRule ^index\.php(.*)$ $1 [R=301,NS,L]
RewriteRule ^(/)?$ index.php/$1 [L]
# make HTTP Basic Authentication work on php5-fcgi installs
<IfModule mod_fcgid.c>
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
# Send request via index.php if not a real file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# deal with php5-cgi first
<IfModule mod_fcgid.c>
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
<IfModule !mod_fcgid.c>
# for normal Apache installations
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
# for Apache FGCI installations
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
</IfModule>
</IfModule>
Pages that actually exist get loaded.
404s work correctly, loading a 404 page:
2015-11-04T19:13:55.489566+00:00 heroku[router]: at=info method=GET path="/admin/test/" host=my.url request_id=b4c4853b-69fe-444e-b03b-5eea7c10b018 fwd="73.218.177.115" dyno=web.1 connect=1ms service=15ms status=404 bytes=6156
Locations that should "exist" by being redirected to FuelPHP get redirected down to the base URL..
I try to load my.url/admin or my.url/admin/clients and I'm redirected to my.url.
2015-11-04T19:14:08.858400+00:00 heroku[router]: at=info method=GET path="/admin/" host=my.url request_id=7a16369b-e647-4399-b11d-a1522d9766a7 fwd="73.218.177.115" dyno=web.1 connect=3ms service=19ms status=302 bytes=1235
2015-11-04T19:14:08.894102+00:00 heroku[router]: at=info method=GET path="/" host=my.url request_id=5780087d-0847-40e6-9a44-b0dabd58577e fwd="73.218.177.115" dyno=web.1 connect=1ms service=5ms status=200 bytes=205
2015-11-04T19:14:08.854106+00:00 app[web.1]: 10.63.87.95 - - [04/Nov/2015:19:14:08 +0000] "GET /admin/ HTTP/1.1" 302 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36
2015-11-04T19:14:08.889796+00:00 app[web.1]: 10.63.87.95 - - [04/Nov/2015:19:14:08 +0000] "GET / HTTP/1.1" 200 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36
2015-11-04T19:14:18.756248+00:00 heroku[router]: at=info method=GET path="/" host=my.url request_id=6eb6d76e-9f0c-4be0-b52a-220a459b9c57 fwd="73.218.177.115" dyno=web.1 connect=1ms service=4ms status=200 bytes=205
2015-11-04T19:14:18.715333+00:00 app[web.1]: 10.63.87.95 - - [04/Nov/2015:19:14:18 +0000] "GET /admin/clients/ HTTP/1.1" 302 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36
2015-11-04T19:14:18.719632+00:00 heroku[router]: at=info method=GET path="/admin/clients/" host=my.url request_id=b15304cf-cd01-4cd6-9613-71d332fcc5a4 fwd="73.218.177.115" dyno=web.1 connect=1ms service=19ms status=302 bytes=1235
2015-11-04T19:14:18.752065+00:00 app[web.1]: 10.63.87.95 - - [04/Nov/2015:19:14:18 +0000] "GET / HTTP/1.1" 200 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36
Slightly modified app/classes/controller/admin.php
public function action_login()
{
// Already logged in
Auth::check() and Response::redirect('admin');
$val = Validation::forge();
if (Input::method() == 'POST')
{
$val->add('email', 'Email or Username')
->add_rule('required');
$val->add('password', 'Password')
->add_rule('required');
if ($val->run())
{
if ( ! Auth::check())
{
if (Auth::login(Input::post('email'), Input::post('password')))
{
// assign the user id that lasted updated this record
foreach (\Auth::verified() as $driver)
{
if (($id = $driver->get_user_id()) !== false)
{
// credentials ok, check access level
$user = Model\Auth_User::find($id[1]);
// ADDED THIS TO CHECK ADMIN LEVEL ACCESS
if ($user->group >= 80) {
//logged in! yay!
$current_user = $user;
Session::set_flash('success', e('Welcome, ' . $current_user->username));
Response::redirect('admin');
}
else {
$this->template->set_global('login_error', 'No access!');
break;
}
}
}
}
else
{
$this->template->set_global('login_error', 'Login failed!');
}
}
else
{
$this->template->set_global('login_error', 'Already logged in!');
}
}
}
$this->template->title = 'Login';
$this->template->subtitle = 'See all the things!';
$this->template->content = View::forge('admin/login', array('val' => $val), false);
}
Thoughts?
I'm quite new to Nginx and I'm testing out if this is the way to go for me in the future. On my server there are a couple of websites. I managed to set up Nginx correctly. However, on the old setup there was a .htaccess file, which made sure all the urls worked correctly.
This is the .htaccess file:
RewriteEngine on
RewriteBase /
RewriteRule ^verzekeringen/([a-z]+)$ products/product/index.php?page=$1 [L]
RewriteRule ^hypotheken/([a-z]+)$ products/product/index.php?page=$1 [L]
RewriteRule ^verzekeringen$ products/index.php?type=1 [L]
RewriteRule ^hypotheken$ products/index.php?type=2 [L]
An online converter, converted this to:
# nginx configuration
location /verzekeringen {
rewrite ^/verzekeringen/([a-z]+)$ /products/product/index.php?page=$1 break;
}
location /hypotheken {
rewrite ^/hypotheken/([a-z]+)$ /products/product/index.php?page=$1 break;
}
location = /verzekeringen {
rewrite ^(.*)$ /products/index.php?type=1 break;
}
location = /hypotheken {
rewrite ^(.*)$ /products/index.php?type=2 break;
}
In the standard configuration file, there is this part, where I think it should be. The problem however, is that I don't really know how to incorporate this into the file.
server {
server_name testwebsite.nl www.testwebsite.nl;
root /var/www/testwebsite.nl/htdocs;
location ~ \.php$ {
root /var/www/testwebsite.nl/htdocs;
fastcgi_pass ***.*.*.*:****;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
You can actually paste the generated rules as is anywhere before ~ \.php$ rule.
you can also try this folded also :
server {
server_name testwebsite.nl www.testwebsite.nl;
root /var/www/testwebsite.nl/htdocs;
location /verzekeringen {
rewrite ^/verzekeringen/([a-z]+)$ /products/product/index.php?page=$1 break;
}
location /hypotheken {
rewrite ^/hypotheken/([a-z]+)$ /products/product/index.php?page=$1 break;
}
location = /verzekeringen {
rewrite ^(.*)$ /products/index.php?type=1 break;
}
location = /hypotheken {
rewrite ^(.*)$ /products/index.php?type=2 break;
}
location ~ \.php$ {
root /var/www/testwebsite.nl/htdocs;
fastcgi_pass ***.*.*.*:****;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
See directive location and rewrite.
location ~ ^/verzekeringen$ {
rewrite ^(.*)$ /products/index.php?type=2 last;
}
location ~ ^/hypotheken$ {
rewrite ^(.*)$ /products/index.php?type=1 last;
}
location ~ /verzekeringen/[a-z]+$ {
rewrite ^/verzekeringen/(.*)$ /products/product/index.php?page=$1 last;
}
location ~ /hypotheken/[a-z]+$ {
rewrite ^/hypotheken/([a-z]+)$ /products/product/index.php?page=$1 last;
}
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} \.(jpg|jpeg|png|gif)$ [NC]
RewriteCond %{REMOTE_ADDR} !^(127.0.0.1|XXX.254.185.XXX)$ [NC]
RewriteCond %{REMOTE_ADDR} !^66.6.(32|33|36|44|45|46). [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?(www.mydomain.org|pinterest.com|tumblr.com|facebook.com|plus.google.com|twitter.com) [NC]
RewriteCond %{HTTP_USER_AGENT} !(googlebot|Googlebot-Image|) [NC]
RewriteRule (.*) byrev-wp-picshield.php?key=ABCD&src=$1 [L]
</IfModule>
I have change this rule for ngnix through this website http://winginx.com/htaccess but it's not working..
Got same problem, and convert .htaccess rule with anilcetin.com.
And now, it's working.
THis is the sample
#HOTLINK PROTECTION START
if ($uri ~* ".(jpg|jpeg|png|gif)$"){
set $rule_0 1$rule_0;
}
if ($remote_addr !~* "^(127.0.0.1|xxx.xxx.xxx.xxx)$"){ #xxx.xxx.xxx.xx is your server ip
set $rule_0 2$rule_0;
}
if ($remote_addr !~* "^66.6.(32|33|36|44|45|46|40)."){
set $rule_0 3$rule_0;
}
if ($http_referer !~* "^http(s)?://(www.)?(www.findhomeideas.info|translate.google.com|translate.googleusercontent.com|www.microsofttranslator.com|pinterest.com|tumblr.com|facebook.com|plus.google|twitter.com|googleapis.com|googleusercontent.com|ytimg.com|gstatic.com)"){
set $rule_0 4$rule_0;
}
if ($http_user_agent !~* "(googlebot|msnbot|baiduspider|slurp|webcrawler|teoma|photon|facebookexternalhit|facebookplatform|pinterest|feedfetcher|ggpht)"){
set $rule_0 5$rule_0;
}
if ($http_user_agent !~* "(photon|smush.it|akamai|cloudfront|netdna|bitgravity|maxcdn|edgecast|limelight|tineye)"){
set $rule_0 6$rule_0;
}
if ($http_user_agent !~* "(developers|gstatic|googleapis|googleusercontent|google|ytimg)"){
set $rule_0 7$rule_0;
}
if ($rule_0 = "7654321"){
rewrite /(.*) /byrev-wp-picshield.php?key=xxxx-xxxx&src=$1 last; #xxx-xxx is your key
}
#HOTLINK PROTECTION START