Wednesday, January 26, 2011

Rewrtie - ignore strings in URI

Hi!

I have some problem with rewrite rules. Now my config looks like this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond ${REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} ^/video/(.*)$
RewriteRule ^(.*)$ /video/index.php [L]

So links example.com/video/?p=2231&c=395840&s=849264&l=101641 works fine.

Why i need is to allow put any string beetween video/ and ?p=2231&c=395840&s=849264&l=101641 for SEO. For ex. example.com/video/string/string/?p=2231&c=395840&s=849264&l=101641 and dont map /string/string/ to index.php.

So i was try somthing like this: RewriteRule ^video/(.+)/(.+)/(.+)$ /video/$3 [L], but this rule dont work.

Any idea how to solve it?

Thank you!

  • If you only need Query String parameters, you can try this RewriteRule:

    RewriteRule ^video(.*) /video/index.php [QSA,L]
    

    QSA Flag will "forward" parameters to next script (ie index.php).

    lurtz : Well not only, coz video should be forward to index.php to. So if i type /video/string/string/?p=id index.php should get /video/?p=id without /string/string/.
    Pierre-Yves : This rewrite will do that. But, user will still see first URL. If you need to explicitely redirect the user, change RR flags to [QSA,L,R=301]

0 comments:

Post a Comment