how to add timthumb rewrite after theme set up - wordpress

here is my htaccess rewrite rule for my theme's timthumb script.
RewriteRule ^pics/([0-9]+)x([0-9]+)x([0-9]+)x([0-9]+)/(.*)$ wp-content/themes/mt_movie/crop.php?src=$5&h=$1&w=$2&q=$3&zc=$4 [L]
I found a text about rewrite rules, on wp codes docs pages.
But i don't know what should i do / or how can i use my RewriteRule via this functions.
Here is the doc link : http://codex.wordpress.org/Rewrite_API/add_rewrite_rule
Actually i want to add this rule after when my theme activated on my customer's web site?
Could anyone help me about this.
Thanks.

This is an Apache rewrite rule. It should go in the .htaccess file in the wordpress directory on your server, assuming that your web server is apache.

Related

Rewrite/Redirect all "someaddress.html" pages to "someaddress/" WordPress

I recently migrated my website - and part of this migration was changing from static html to a wordpress website. All of my links to my site still use the following scheme: mysite.com/{year}/{month}/somepost.html whereas my new scheme is mysite.com/{year}/{month}/somepost/
How can I redirect (301) using mod_rewrite all URLs with the old pattern to the new one?
Using mod_rewrite you can set your .htaccess file to redirect the incoming links from http://example.com/2004/04/title_of_post.html to http://example.com/2004/04/title-of-post/ by:
RewriteEngine on
RewriteRule ^([0-9]{4}/[0-9]{1,2}/.*)\.html $1/ [R=301,L]
There is also a plugin for wordpress, you may have a look link

Removing Wordpress directory name from certain URLs using .htaccess

So I have one Wordpress install in a sub-directory. (www.mysite.com/wp/)
What I need is for certain pages to remove the WP directory name from the URL.
so 'www.mysite.com/wp/careers' needs to be -> 'www.mysite.com/careers'
I have an .htaccess in the root directory and in the wp directory. I've gotten some of my rules to work when permalinks are disabled in WP, but when those are enabled (which they need to be) the WP .htaccess overrides any rules I have in the root.
Is there any way to have 2 htaccess co-exist in this manner? Sorry I haven't messed with wordpress and apache very much.
Any input is greatly appreciated.
**So I finally got this working, it was just a matter of like you said formatting redirect URL so wordpress likes it.
So in my root htaccess file : for this url mysite.com/careers
RewriteRule ^careers/?$ wp/index.php?pagename=careers [L]
And voila and it started working just fine.
Yes, you can have rules in both htaccess files but it's going to be tricky as wordpress has specific ways that it will expect URLs to look.
In the wordpress htaccess file, above any wordpress related rules, add:
RewriteCond %{THE_REQUEST} \ /+wp/careers
RewriteRule ^ /careers [L,R]
then in the htaccess file in the document root add:
RewriteRule ^careers$ /wp/careers [L]
But again, depending on what wordpress expects the "careers" URL to look like, this may not solve your problem.

url rewrite using htaccess to force load index.php

I'm trying to make a user-friendly author page url for my wp site. Currently what I have done is I have created a folder by name author under my root theme folder and I have put my author page mark-up file(index.php) inside this folder.
I also have a plugin 'Easy url rewrite' which I'm using to make www.sitename.com/author request to load <theme dir>/author/index.php file. And it is working fine.
Now I want any www.sitename.com/author/<anyname> also to load my index.php file.
Can I achieve this using .htaccess rules? Does .htaccess rule conflict with my url-rewrite plugin?(which one will be executed first?) Can I achieve this whole thing using only .htaccess rules(ie., without the use of plugin rewrite) If so, What rules do I need to write in .htaccess file?
Thanks! Greatly appreciate your help.
Does .htaccess rule conflict with my url-rewrite plugin
yes, probably.
which one will be executed first?
The htaccess rules get executed first, but that's part of how wordpress works. There are rules that essentially send everything to wordpress' controller and then wordpress handles it from there.
Can I achieve this whole thing using only .htaccess rules
It depends. Is your page generated by wordpress or is it just a page by itself separate from wordpress? If it's the former, you're going to need to work on some more easy url rewrite rules, if the author page is separate from wordpress then you can do this entirely with htaccess.
If that's the case, I'd guess the rules would look something like:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^author/(.*)$ /themedir/author/index.php [L]
Those rules need to be before any wordpress rules that you have in the htaccess file in your document root.

static to static url rewrite with htaccess with wordpress

I have a wordpress site with its own .htaccess automatically generated (because I'm using permalinks), than, my web-admin has configured apache to redirect any third level domain to my site, ie :
http://lol.example.com redirects to http://example.com
and than .htaccess with permalinks rules does the rest.
Now I want to write a rule in the .htaccess file that, when a user types a specific third level domain, redirects to a specific subfolder of my site, ie:
http://sprock.example.com/ redirects to http://example.com/mysprockfolder/
I know my question might sound weird, but I've never done this before so I'm quite confused.
Solved with that regex in my .htaccess:
Right before this comment (just in case you have WordPress installed):
# BEGIN WordPress
I've added the following:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?thirdlev\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/myfolder/ [R=302,L]
with a 302 redirect, everything is good!
it would be much easier for you to just go to your ftp manager and make a subdomain forward to a link. Or, you can make a redirect using php.
when redirecting make sure to add the http://www. or it will think you want to redirect to a part of your page on the site, also make sure that your subdomain has its own folder with its own files and images.

URL rewriting For WordPress - Integrating Non Wordpress site with wordpress

We are unable to change the url rewriting to integrate an exsiting directory site into my wordpress site.
WordPress is fixing everything to their url pattern.
How can I help my programmer? Can someone give an advise?
More details would be useful, but in all likelihood, add a do nothing and stop rule for your folder before the WP rules:
RewriteEngine On
RewriteBase /
RewriteRule ^folder - [L]
We integrate WordPress with Ruby-on-Rails on ICanLocalize.
This is done in the Apache config file. Use the Apache Alias command to indicate that a path comes from a different physical directory.
Then, the URLs that match that path will never go to WordPress. They will be served from the other physical directory, where you can place anything.
If you need to take a subdirectory out of the url-rewriting from wordpress, put an additional .htaccess file into that directory and switch the Rewrite-Engine off:
RewriteEngine Off
That directive overrides any settings of the wordpress .htaccess for that directory and it's subdirectories.
You find the longer version of my answer in a related question on wordpress answers with a slightly different .htaccess code.

Resources