0

I am having the following two urls that give me some nasty 404 errors that I would like to fix by adding some rewrite rules to apache and I must recongnize that I don't understand regular expressions enough to be able to write the correct rules.

FIRST URL

http://www.example.com/fincas-rusticas/finca-rustica_en_alacant-alicante/lalacanti/alicante/function.strtotime

Must redirect to the same url without /function.strtotime at the end.

SECOND URL, nasty one.

http://www.example.com/casas/casas_en_malaga/malaga/malaga/
Strict Standards: Only variables should be passed by reference in /var/www/vhosts/eldeposit.com/httpdocs/protected/helpers/Search.php on line 1398
/casas/casas_en_malaga/malaga/malaga/venta-vivienda-29-473-24693-0-0

This one must remove the part with the strict standards error. I don't know if it even can be done with a regular expressions or I better program it in php

M'vy
  • 5,696
  • 2
  • 30
  • 43

2 Answers2

2

1) Use this rule -- it will remove function.strtotime from end of URL (by using 301 Permanent Redirect) regardless of how deep that part is in URL (i.e. it will work for example.com/something/function.strtotime as well as example.com/one/two/three/function.strtotime).

RewriteEngine On
RewriteBase /

RewriteRule ^(.*)function\.strtotime $1 [L,R=301]

2) This cannot be fixed by using .htaccess. It is error in your PHP code (sounds like you've passed value directly instead of assigning it to variable first and passing variable) and has to be fixed in PHP code.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • hi LazyOne and thanks for your answer, the 2nd point is not about the php error, you have got it wrong, the problem is that when that error ocurred on the page it was inside of the HREF attribute of the link, so the link became that ugly huge piece of text and Google readed it as a link and started indexing it – Alexandru Trandafir Catalin Jul 18 '11 at 16:20
  • as you can see here: REQUEST_URI=/pisos/piso_en_melenara/-/-/%3Cbr%20/%3E%3Cb%3EStrict%20Standards%3C/b%3E:%20%20Only%20variables%20should%20be%20passed%20by%20reference%20in%20%3Cb%3E/var/www/vhosts/example.com/httpdocs/protected/helpers/Search.php%3C/b%3E%20on%20line%20%3Cb%3E1398%3C/b%3E%3Cbr%20/%3E/pisos/pisos_en_melenara/gran-canaria/palmas-las/venta-vivienda-35-459-36428-0-0 – Alexandru Trandafir Catalin Jul 18 '11 at 16:21
  • @Alexandru So .. how do you propose this to be fixed. It should not be a problem to write a rule .. but since I do not know your app and how the proper link should be, I do not know where to start. Please describe exactly what is your idea on fixing this. – LazyOne Jul 18 '11 at 17:13
  • well the bad part of the url starts with
    and ends with
    the correct url would be: /pisos/piso_en_melenara/-/-/pisos/pisos_en_melenara/gran-canaria/palmas-las/venta-vivienda-35-459-36428-0-0 so my oppinion would be to try to catch all parts of the string inside the regex variables $1,$2 and so on, and on the redirect side just put the ones that instest us, and leave out the one with the useless text, I just don't know how to properly implement it, also the url that you see above as I said, the text to be removed starts with
    , the url pasted above is encoded for the spaces
    – Alexandru Trandafir Catalin Jul 19 '11 at 08:30
0

For the first one you can do

RewriteRule fincas-rusticas/finca-rustica_en_alacant-alicante/lalacanti/alicante/function.strtotime fincas-rusticas/finca-rustica_en_alacant-alicante/lalacanti/alicante/ [L]

For the second one, I must assume that this URL is already rewritten to something, since the strict standard error is a PHP error. This mean you address is somewhere processed.

If the URL should be processed as by the script is it redirected to, I guess you can refer to : Strict Standards: Only variables should be passed by reference

If the URL should yield a forbidden error, you can do

RewriteRule casas/casas_en_malaga/malaga/malaga/ - [F]
Community
  • 1
  • 1
M'vy
  • 5,696
  • 2
  • 30
  • 43