Timthumb.php Rewrite Seo Friendly URL (Nginx) - nginx

I started using nginx today.
These codes was working well rewrite on Apache.
RewriteRule ^thumb/(.*)x(.*)_(.*) styles/timthumb.php?src=http://image.mysite.org/uploads/$3&h=$2&w=$1&zc=1 [NC,L]
Url structure like this
http://www.mysite.org/styles/timthumb.php?src=http://image.mysite.org/uploads/fasulye.jpg&h=134&w=228&zc=1
To
http://www.mysite.org/thumb/228x134_fasulye.jpg
I want make friendly seo link of thimtumb with Nginx. Please help me. :(
Sorry my bad English.

You don't need to change much of the apache format
rewrite ^thumb/(.*)x(.*)_(.*) styles/timthumb.php?src=http://image.mysite.org/uploads/$3&h=$2&w=$1&zc=1 last;

Related

How can I convert this Apache code to work in NGINX?

I have a file - sitemap.php - which when called shows the same kind of content you might expect from a sitemap.xml file.
I want it so when I go to the URL /sitemap.xml it is actually showing the content that would be showed if you went to /sitemap.php
This used to be achieved by using .htaccess but we don't use Apache now.
RewriteRule ^/sitemap.xml$ sitemap.php [L]
I did try some kind of "apache to nginx" converter thing online but I'm not too fluent in NGINX config code so couldn't say if it was right or wrong.
Sure. Put into your server configuration block before any defined locations this line:
rewrite ^/sitemap.xml$ /sitemap.php last;

.htaccess rewrite domain.com/en/multisite to domain.com/multisite/en

I'm using multisite WordPress and qTranslateX plugin. My default website is in Bahasa and my second language is English. When I use custom link in mode language English like mydomain.com/multisite, it always added by "en" after mydomain.com, it will be mydomain.com/en/multisite. That link always return 404 because there is no page.
I want to use .htaccess to rewrite URL form mydomain.com/en/multisite to mydomain.com/multisite/en .
Thanks in advance
Unfortunately, you can't achieve that with mod_rewrite alone as far as I know.
Wordpress will look at the REQUEST_URI to figure out what to show, and that one won't be overwritten (and [E=REQUEST_URI:...] will make it $_SERVER["REDIRECT_REDIRECT_REQUEST_URI"]).
If mod_proxy is installed as well, you could do something like this:
RewriteEngine On
RewriteBase /
RewriteRule ^en/([^/]+)(/?.*)$ /$1/en$2 [P,L]
It will proxy the request internally on the same host and server.
Requesting http://example.org/en/test will look to wordpress as if http://example.org/test/en was requested.
Give it a try. If mod_proxy isn't installed, it won't work (and render a 404 for the URL), but it won't break your site, so it's pretty safe to experiment with.

HTACCESS Rule to NGINX Configuration File (One Rule)

I'm struggling with getting one rule that I had in my HTACCESS file, to work within my NGINX configuration files. I've used the converters online, and searched on Google but can't seem to find a solution that'll work. I feel this would be a quick solution for someone a bit more familiar with NGINX redirects. I sure hope so! :-)
HTACESS Rule:
RedirectMatch 301 ^/services/automotive-services/(.*)$ http://www.domain.com/automotive-services/$1
I'm trying to get my NGINX rule to do the following...
http://www.domain.com/services/automotive-services/ should go to http://www.domain.com/automotive-services/
http://www.domain.com/services/automotive-services/pagenamehere should go to http://www.domain.com/automotive-services/pagenamehere
Any assistance with this would be great! :-)
You have to remember that Nginx does not do anything with htaccess files. Htaccess files are purely an Apache construct.
As for how you would do the RedirectMatch in Nginx, put this in your server configuration:
if ( $request_filename ~ services/.+ ) {
rewrite ^(.*) http://www.domain.com/$1 permanent;
}
This will check if $request_filename contains "services", and if it does, it will rewrite it via 301 to http://www.domain.com/.

nginx: Redirect special characters like "%23" in URL to "#"

My nginx site has a few bad links pointing to it like this:
/some-page%23some-part
/some-page">
This is causing 404's and Google Webmaster Tools is complaining too.
The URL /some-page#some-part does get processed properly and works.
How can I get nginx to redirect the %23 in a URL to #? What about the "> junk?
The links out there cannot be changed, so I'm looking to 301 redirect them myself.
Thanks!
Edit: thanks to Deadooshka for the help. My working solution, rewrite ^(.*)\#(.*)$ /$1#$2 redirect;, is discussed within his answer's comment thread.
not tested. I'm not sure which symbols get the pattern.
rewrite ^/([^\#]+)\#([^\#]+)$ /$1#$2 redirect;
rewrite '^/([^\&]+)\&quot\;\&gt\;$' /$1 redirect;

wordpress iis6 permalink /%postname%/ doesnt work IIRF url rewrite needed?

I have a wordpress site on iis6 and I want this:php?id=6 to look like this: /postname/. When I change the permalink I get a 404 error. I have the IIRF proxy extension enabled, and in my root directory I have a IIRF.ini with the following code:
RedirectRule ^/blog/index\.php/(.*)$ /blog/$1 [I,R=301]
RewriteRule ^/blog/(?!index\.php|wp-|xmlrpc)(.*)$ /blog/index.php/$1 [I,L]
Is this code incorrect for a permalink of just /%postname%/?
Thanks
I just installed IIRF 2.1 on Windows Server 2003 running IIS6.
Your address seems to have /blog/ on the very beginning, but I'm afraid we can do it simpler. Bellow, follow my whole Iirf.ini, with a simple permalink working:
# Iirf.ini
#
# ini file for IIRF
#
RewriteEngine ON
StatusInquiry ON
IterationLimit 5
# this will allow ugly URLs to not be processed at all
RewriteRule ^/(?!index.php)(?!wp)([^\.]*)$ /index.php/$1 [I]
Make sure this simple form works, and then add /blog/.
Some literature that may help (it helped me)
http://cheeso.members.winisp.net/Iirf21Help/html/49492102-e623-40d7-9dc3-d1411800be80.htm
http://codehill.com/2009/11/wordpress-permalinks-in-windows-using-iirf/
Cheers!

Resources