Jump to content

willo_the_wisp

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

willo_the_wisp's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, Just to let you know, with your help above and a couple of other sources, I finally cracked it. To save anyone with the same trouble the hours of head-scratching that I've had, here's the solution: #Transform this search-engine-indexed URL: 09search_results.php?search_KEYWORD=aluminium&search_RANGE=Frames&o=1&search=1 #INTO this: /ready-made-frames/some-var/ RewriteCond %{REQUEST_URI} ^/09search_results\.php?$ #Check that the request is for this specific file RewriteCond %{QUERY_STRING} ^search_KEYWORD=([a-z]+)&search_RANGE=([a-z]+)&o=([0-9]+)&search=[0-9]+$ [NC] #Check that the querystring follows this specific format RewriteRule ^(.*)$ /ready-made-frames/%1/? [R=301,L] #Rewrite it into 'friendly URL' format #Variables %2, %3, and %4 are redundant in this new URL structure Thanks for your help AyKay47 and Requinix. We got there in the end!
  2. Hi, I'm still bashing my head against a wall with this. Almost nothing works! My client really needs this to be up and running but I just can't make it work. So, to re-iterate, in my .htaccess file, I have the following: Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} !^www\.sitename\.co.uk$ [NC] RewriteRule ^(.*)$ http://www.sitename.co.uk/$1 [R=301,L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ RewriteRule ^index\.php$ http://www.sitename.co.uk/ [R=301,L] ### RewriteRule Pattern Substitution [OptionalFlags] RewriteRule ^ready-made-frames/?$ ready-made-frames.php [L] # Ready-made frames page # Works fine RewriteRule ^ready-made-frames/([^/\.]+)/?$ frames.php?search=$1 [L] # Ready-made frames category page # Works fine RewriteRule ^ready-made-frames/([^/\.]+)/([^/\.]+)/?$ frame-details.php?search=$2 [L] # Works fine RewriteRule ^frames-by-size/?$ frames-by-size.php [L] # View frames by size page # Works fine RewriteRule ^09search_results.php?search_KEYWORD=aluminium&search_RANGE=Frames&o=1&search=1+$ /ready-made-frames/aluminium/ [R=301,NC,L] #NOTE: This is the simplest example of this rewrite I could find, but it just doesn't work. Google has indexed loads of URLs like the one in the last RewriteRule above. If Google (or another search engine), sends a request to 09search_results.php?search_KEYWORD=aluminium&search_RANGE=Frames&o=1&search=1, what I need it to do is replace the URL in the browser address bar with /ready-made-frames/aluminium/ Simple, you'd think? But I just can't make it work. If I change the last rewrite rule to RewriteRule ^09search_results.php /ready-made-frames/aluminium/ [R=301,NC,L] it works fine. But as soon as I put in any of the querystring, it stops working. The URL in the address bar stays resolutely at 09search_results.php?search_KEYWORD=aluminium&search_RANGE=Frames&o=1&search=1, rather than being replaced. Please please if anyone can help, I'm getting really frustrated with this. Thanks to AyKay47 and Requinix for suggesting solutions before, but they didn't work either :-(
  3. Hi AyKay47, I think you've misunderstood me. 09search_results.php?search_KEYWORD=aluminium&search_RANGE=Frames&o=1 is the OLD URL, which has been cached by Google, and therein lies the problem. Google will send traffic to 09search_results.php?search_KEYWORD=aluminium&search_RANGE=Frames&o=1 for the next few months, until Google eventually removes it from its index. Therefore if Google sends someone to that URL, I need it to redirect the page to /frames/aluminium/1 I've already got a rule to redirect /frames/aluminium/1 to frames.php, which is working. But I can't get any .htaccess rules (including yours) to work to do the first part. Willo
  4. Hi Requinix, Unfortunately that doesn't work either... it causes a 500 error. Kelly
  5. Hi AyKay47, Yes I thought you'd written it backwards the first time, but I tried swapping it around myself but it didn't work. Unfortunately your last solution above doesn't work either! I'm really scratching my head with this one. My other rules work, but not this one!! Any more advice you can offer would be appreciated! Willo
  6. Hi AyKay47, Thanks for your reply, much appreciated. Looking at your solution, I was full of hope that it would work... but it doesn't unfortunately. I didn't give you many values because there are literally thousands of combinations, hence the reason I need a Rewrite rule to take care of them. search_KEYWORD can be 'aluminium','black','silver','birch', and lots of other values. search_RANGE can be 'Frames','Prints','Photos' and lots of others. $o is a parameter for the database offset, and can be anything from 1 - 1000+ $search I think can be 0 or 1 but it wouldn't surprise me if it could be 0 - 9 given the way the previous developer has put this site together. I tried your rule in my .htaccess file and it had no effect at all. /09search_results.php?search_KEYWORD=aluminium&search_RANGE=Frames&o=1&search=1 stubbornly refuses to be translated to /frames/aluminium/1 Here's what I have in my .htaccess file at the moment: Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} !^www\.sitename\.co.uk$ [NC] RewriteRule ^(.*)$ http://www.sitename.co.uk/$1 [R=301,L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ RewriteRule ^index\.php$ http://www.sitename.co.uk/ [R=301,L] ### RewriteRule Pattern Substitution [OptionalFlags] RewriteRule ^ready-made-frames/?$ ready-made-frames.php [L] # Ready-made frames page RewriteRule ^frames/([^/\.]+)/?$ frames.php?search=$1 [L] # Ready-made frames category page RewriteRule ^frames/([^/\.]+)/([^/\.]+)/?$ frame-details.php?search=$2 [L] RewriteRule ^frames-by-size/?$ frames-by-size.php [L] # View frames by size page #RewriteRule frames/([^/\.]+)/([0-9]*)$ frames.php?search=$1&page=$2 #Ready-made frames + pagination #RewriteRule ^/09search_results.php?search_KEYWORD=aluminium&search_RANGE=Frames&o=1&search=1 /frames/aluminium/ [L,R=301] RewriteRule ^/([a-z]+)/([a-z]+)/([0-9]+)$ /09search_results.php?search_KEYWORD=$1&search_RANGE=$2&o=$3 [NC, L] #ErrorDocument 400 /400.php #ErrorDocument 401 /401.php #ErrorDocument 403 /403.php #ErrorDocument 404 /404.php #ErrorDocument 500 /500.php Everything's working apart form the 09search_results.php rule. Any more ideas? Thanks, Willo
  7. Hi all, I've just taken control of a site (written by another developer), which has a load of unfriendly URLs that the client would like me to make 'friendy'. I've done this using .htaccess and mod-rewrite I need to re-write URLs such as the following, but don't know how to write the rules to do so. An example of the type of URL I have to convert is as follows: /09search_results.php?search_KEYWORD=aluminium&search_RANGE=Frames&o=1&search=1 Needs to become: /frames/aluminium/1 I need to pattern match &0=1 and $search=1 as these are variable and there are hundreds of variations. &o will become the number at the end of the friendly URL. &search can be discarded. I thought I'd need to do something like this in .htaccess: Redirect 301 09search_results.php?search_KEYWORD=aluminium&search_RANGE=Frames&o=1&search=1 /frames/aluminium/ However I can't make this work at all. Can anyone please help?
  8. Hi, I'm creating a PDF document using the FPDF library. All is fine, using a sample image that came with the library. However, I need to get the data for the PDF from a database. The data's fine - the query is performed and the data prints out as I need. However, there's one line which takes a value which is a filepath. When I put that into the following line, I get an error from FPDF: Code: $this->Image($row['imgpath'],10,10,190); Error produced: FPDF error: Image file has no extension and no type was specified: However, if I print out the value of $row['imgpath'] and manually insert it into the code as follows, it works fine: Code: $this->Image('../assets/images/products/5777A.jpg',10,10,190); I've come across this problem once before but can't for the life of me remember what the solution was. It was something to do with how I was reading the value into the code, I think. Can anyone jog my memory, please??
  9. Hi, I've written a script for a client which creates a folder on the server using mkdir. The client wanted this folder to be created for them (don't ask why, it's complicated!), then they wanted to be able to FTP in and add files into the folder using FTP. The problem is that the script creates the file with a group of 99. When the client tries to FTP in and add their files, they get the following error: '550 Can't create directory: Permission denied', presumably because they're in a different group. What I need to be able to do is get the script to create a folder with a different group, so that my client can FTP their files into it. I thought I would be able to use PHP's chgrp after mkdir, as follows: mkdir($filepath, 0777) chgrp($filepath, 501); However then I get "Warning: chgrp() [function.chgrp]: Operation not permitted". I realise from reading the manual that I need to be a superuser to do this, which my web script obviously isn't. My question is, how can I get around this? Is there some setting in Apache that I can set? Thanks in advance for any help! Willo
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.