Hi, I want to "compress" timthumb.php urls like:
http://mydomain.com/wp/themes/mymagazinetheme/timthumb.php?
src=http://mydomain.com/wp/media/sampleimage.jpg&h=400&w=580&zc=1
to:
http://mydomain.com/wp/media/sampleimage-400-580-1.jpg
Is it possible?, so please help me here is my thumb.php file.
This is kind of long, but maybe you're looking for something like this?
RewriteRule ^wp/media/([^\-/]+)-([0-9]+)-([0-9]+)-([0-9]+)\.(jpe?g|png|gif|bmp)$ /wp/themes/mymagazinetheme/timthumb.php?src=http://%{HTTP_HOST}/wp/media/$1.$5&h=$2&w=$3&zc=$4 [L,R=301]
Related
I know almost nothing so there may be the problem! But I've tried snippets fro 20 different answers to try and get this and no joy. I have a form on one page which will not work on iPhone or Safari. So I have a second form which will. I need to redirect a single page (https://website.co.uk/normal-page/) to another page (/mobilepage/) only if the browser is Safari, or the device an iPhone.
Here's one effort:
RewriteCond %{HTTP_USER_AGENT} "iphone|safari" [NC]
RewriteCond %{REQUEST_URI} ^/normal-page/$ [NC]
RewriteRule (.*) %{HTTP_HOST}/mobilepage/ [NC,R=301]
Which stops any access to the page at all - which was a great improvement on no effect. I'm sure it's simple but I can't get it to work.
Thanks in advance.
I hope this is the right place to post this. Eventually I found the HTACCESS route didn't work. Different OS/Browser combos seemed to arbitrarily ignore or apply the rules when they shouldn't. So I went for Javascript. Less robust, as a user may have it disabled, but I'm not clever enough to find anything better.
Since I found this whole process hard to find answers for I thought I'd post my solution up here - but with the caveat that I'm very much an amateur poking about - there my be better ways and better code.
<script type="text/javascript">
jQuery(document).ready(function(){
var FormSafe = 1;
if (window.navigator.userAgent.indexOf("Windows")!== -1) FormSafe=2;
if (window.navigator.userAgent.indexOf("Chrome")!== -1) FormSafe=3;
if (window.navigator.userAgent.indexOf("OPR")!== -1) FormSafe=4;
if (window.navigator.userAgent.indexOf("Android")!== -1) FormSafe=5;
if (window.navigator.userAgent.indexOf("BlackBerry")!== -1) FormSafe=6;
if (window.navigator.userAgent.indexOf("Firefox")!== -1) FormSafe=7;
if (window.navigator.userAgent.indexOf("iPhone")!== -1) FormSafe=1;
if (window.navigator.userAgent.indexOf("iPad")!== -1) FormSafe=1;
if ( FormSafe === 1 ) {
jQuery("#iphoneform").show(); } else
{ jQuery("#normalform").show(); }
});
</script>
I used 1-7 just to bug test by seeing the results. It could just be ==1 for good, 0 for bad for all others. But 1-7 means you could show different div for each browser.
Then it simply shows or hides the element with a form which works for whichever browser/OS combo.
Hope it helps someone.
This doesn't work for three reasons. First of all, your 2nd RewriteCond will only work with /normal-page/. So if the trailing slash isn't there, it will not pick up the URL. Using /normal-page fixes this and works with and without the trailing slash.
The biggest issue was with your rewriterule. Your were basically trying to rewrite the URL to: http://example.com/example.com/mobilepage/ which is obviously breaking your page.
You also shouldn't need the "" around your first Condition.
Use these rules instead:
RewriteCond %{HTTP_USER_AGENT} iphone|safari [NC]
RewriteCond %{REQUEST_URI} ^/normal-page [NC]
RewriteRule ^(.*)$ /mobilepage/ [L,R=301]
Make sure you clear your cache before testing this. Also, keep in mind that R=301 is a permanent redirect, I advise you change this to R=302 while testing, this is a temporary redirect.
In WordPress I'm using the Events Manager plugin, which uses the /events/subpage path in the URL.
I need to tweak things slightly so that /courses/subpage rewrites to /events/subpage i.e. the content of /events/subpage is shown when going to /courses/subpage. The URL should stay as /courses.
I thought this rule would do it:
RewriteRule ^courses/?(.*)$ /events/$1 [L]
But the URL changes from /courses to /events so it looks like my rule isn't quite right.
EDIT
Strangely I can put anything in place of /courses and it resolves to /events anyway. Confused!
Think I’ve cracked it.
I uninstalled the rewrite plugin and replaced it with Rewrite Rules Inspector. Then I added the following to functions.php
add_rewrite_rule(‘^course/([^/]*)/?’, ‘index.php?event=$matches[1]‘, ‘top’); // single event
In Rewrite Rules Inspector is said the rule was missing. I flushed the rules using the plugin and everything appears to be working now. It looks like the original rewrite plugin wasn’t flushing the rules properly.
I am starting to use mod_rewrite and would like to know if the below is possible...
RewriteRule ^test/([^/]*)/$ /test.php?x=$1 [NC,L]
That works as expected however, once the HTML generates I use relative paths to images/stylesheets etc such as <img src="include/image.jpg" /> which now no longer shows.
How can I get around this?
Many Thanks
One way to do it is to add a rule to skip requests that end in standard image file suffixes:
RewriteRule \.(gif|jpe?g|png|ico)$ - [NC,S=1]
RewriteRule ^test/([^/]*)/$ /test.php?x=$1 [NC,L]
There are several possibilities:
Don't use relative paths.
Add a <base> tag to your HTML.
Rewrite the image URLs too:
RewriteRule ^test/include/(.*)$ /include/$1 [NC,L]
i am using IIRF v2.1 for Rewrite Rule
i write on rule like this but its not working
RewriteRule ^(prod|pag|staf)/([A-Za-z0-9-]+)/?$ $1.php?iid=$2 [QSA,L]
if i use follwoing url
http://localhost/prod/22/new-item
what i need actual URL is
http://localhost/prod.php?iid=22
yes working version is
RewriteRule /^(prod|pag|staf)/([A-Za-z0-9-]+)/?$ /$1.php?iid=$2 [QSA,L]
but problem here is all the style and include files are not included.
Thanks
just write url like this
RewriteRule ^/(prod|pag|staf)/([A-Za-z0-9-]+)/?$ /$1.php?iid=$2 [QSA,L]
and put / before your style sheets and other includes
like
if your old style sheet is include like this
style/style.css
chnage it to
/style/style.css
same for image and links.
hope this will work fine.
Your regex doesn't allow for new-item to follow the final slash.
RewriteRule ^(prod|pag|staf)/([A-Za-z0-9-]+)/?$ $1.php?iid=$2 [QSA,L]
The /?$ sequence that ends the pattern says... a slash (maybe) and then the end of the string. Your URL, however, does not end in a slash. It ends with a slash and the text "new-item".
A regex that captures that would be something like this:
RewriteRule ^(prod|pag|staf)/([A-Za-z0-9-]+)/? $1.php?iid=$2 [QSA,L]
...which says, you don't care what comes after the optional slash, and because you are using QSA, then any query string in the original URL is appended to the outgoing URL.
But that would basically discard the "new-item" portion of the incoming URL request, which I am not sure you want to do.
If you're URLs will always contain the numbers then the slug, this regex will get each part:
^(prod|pag|staf)/([0-9]+)/([A-Za-z0-9-]+)/?
I have a page called "user" and on that page I show stats about specyfic user,but the url is like http://somepage.com/user/?u=ID , I want to make http://somepage.com/user/ID , tried htaccess, but no result
I would've said htaccess but you say no result?
Are you sure you did it right?
RewriteEngine On
RewriteBase /
RewriteRule ^user/([.]+)$ user/?u=$1
or something like that.
Sorry if I'm teaching to suck eggs, but at least you can tick it off with someone else giving you the same thing you've tried :)
edit:
OK you've tried that. Now I'm guessing we're looking at this the wrong way?
RewriteRule ^user/?u=([.]+)$ User/$1
I'm not sure if wordpress will understand this though.
Or just use google and the first result is...
http://teamtutorials.com/web-development-tutorials/clean-url’s-with-wordpress