Forum Moderators: phranque

Message Too Old, No Replies

Forms and Mod rewrite

I'm stuck

         

dqiria

2:41 pm on Aug 3, 2008 (gmt 0)

10+ Year Member



Hello, I want to make URL-s from $_GET SEO friendly.

I'm using this code in .htaccess:

RewriteRule ^([^_]*)_([^_]*)\.html$ /index.php?category=$1&make=$2&go=go [L]

But it's working only when I type URL myselft. (like [localhost...]

I tried to use php header("location...), but it gives this error:

Redirect Loop

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

The browser has stopped trying to retrieve the requested item. The site is redirecting the request in a way that will never complete.

* Have you disabled or blocked cookies required by this site?
* NOTE: If accepting the site's cookies does not resolve the problem, it is likely a server configuration issue and not your computer.

So, what to do? :(

jdMorgan

3:35 pm on Aug 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I tried to use php header("location...), but it gives this error:

Redirect Loop

Why are you trying to use a "Header: Location" redirect? What are you trying to accomplish with it?

It should not be necessary to do such a redirect in PHP; Simply generate URLs like "http://example.com/x_y.html" as your on-page links, and then let your mod_rewrite rule internally rewrite that to "/index.php?category=x&make=y&go=go"

To be clear: The links that appear on your pages must now use the new "friendly" URLs.

If you wish to redirect requests for the old dynamic URLs to the new friendly static ones, then you must check the HTTP request header to be sure that the client directly-requested an old dynamic URL, and that the URL has not already been rewritten by your .htaccess code. Otherwise, you *will* get a loop.

For more details, see this previous thread: Changing Dynamic URLs to Static URLs [webmasterworld.com]

Jim

dqiria

11:24 am on Aug 4, 2008 (gmt 0)

10+ Year Member



Thank you very much, it solved my problem :-)