PHP page rewrites done, now what does it look like?

Discuss practical ways rearrange URLs using mod_rewrite.

PHP page rewrites done, now what does it look like?

Postby servantofgod » Wed Oct 01, 2008 8:26 am

Nevermind this, taken care of.
servantofgod
 
Posts: 22
Joined: Wed Oct 01, 2008 8:14 am
Location: Chicago

This I could use help on

Postby servantofgod » Wed Oct 01, 2008 10:25 am

Now in my homepage I have a header in which I can change all my URLs now that I have written them from dynamic to static. But there are database generated urls that pop up such as:

For example:, the main page of my site is set to automatically generate a random product display. Hover over one of these products and you will see a url such as:

http://www.whatsshopping.com/productsin ... at=1911440

Now since these random products are generated by the database, I cannot hard-code to change them, like I can change the links in the header, which are hard coded, they are not part of the page itself.

How can I change it so that they are viewed as static urls, meaning 1) If i right click on them, and copy link location, I will copy a static url 2) If I click on them, I will see a static URL in my browser.

If you do not understand me fully go to www.whatsshopping.com, and look below into the featured products.

Thank you much if you can help
servantofgod
 
Posts: 22
Joined: Wed Oct 01, 2008 8:14 am
Location: Chicago

Postby richardk » Wed Oct 01, 2008 11:19 am

You have to edit the PHP script. Have you talked to the authors of the script?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby servantofgod » Wed Oct 01, 2008 11:58 am

Unfortunately they are long gone. I myself can interpret the code they use to pull the information from the database, but I am not familiar how to mix that with the mod rewrites or how to use mod rewrites and reference such.
servantofgod
 
Posts: 22
Joined: Wed Oct 01, 2008 8:14 am
Location: Chicago

Postby richardk » Wed Oct 01, 2008 12:03 pm

They will be echoing out the links, you have to find them and change their format.

For example changing /index.php?a=1&b=2
Code: Select all
echo '<a href="/index.php?a=' . $some_a_var . '&amp;b=' . $some_b_var . '">' . $_some_link_title . '</a>';

you would change it to output the new style link /a/b/
Code: Select all
echo '<a href="/' . $some_a_var . '/' . $some_b_var . '/">' . $_some_link_title . '</a>';
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Ok i see

Postby servantofgod » Wed Oct 01, 2008 1:26 pm

This is what you're referring to I believe:
Code: Select all
<a href="productsincategories.php?ban=<?PHP echo $prod["pSection"]; ?>&cat=<?PHP echo $prod["pID"]; ?>" >


In this case the above code brings dynamic urls such as this:
Code: Select all
/productsincategories.php?ban=540&cat=HBWALKFITRSIZE%20F


How do I get that to bring the static version which is this:
Code: Select all
/productsincategories-ban-540-cat-HBWALKFITRSIZE%20F.htm
[/code]
servantofgod
 
Posts: 22
Joined: Wed Oct 01, 2008 8:14 am
Location: Chicago

Postby servantofgod » Wed Oct 01, 2008 2:03 pm

Tried the following and made the products being called disappear:

Code: Select all
<a href="productsincategories-ban-<?PHP echo $prod["pSection"]; ?>-cat-<?PHP echo $prod["pID"]; ?>.html>
servantofgod
 
Posts: 22
Joined: Wed Oct 01, 2008 8:14 am
Location: Chicago

Postby richardk » Wed Oct 01, 2008 2:29 pm

Post your mod_rewrite.

Try
Code: Select all
.htm">

instead of
Code: Select all
.html>


You may want to use
Code: Select all
<?PHP echo str_replace(array(' ', '%20'), '+', $prod["pID"]); ?>

instead of
Code: Select all
<?PHP echo $prod["pID"]; ?>

so you get + instead of %20 for spaces.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby servantofgod » Wed Oct 01, 2008 2:55 pm

Here's my rewrite:
Code: Select all
RewriteEngine on

RewriteRule categories_and_featured_products-pid-(.*)\.html$ categories_and_featured_products.php?pid=$1

RewriteRule subcategories_and_featured_products-pid-(.*)-cid-(.*)\.html$ subcategories_and_featured_products.php?pid=$1&cid=$2

RewriteRule productsincategories-ban-(.*)-cat-(.*)\.html$ productsincategories.php?ban=$1&cat=$2

RewriteRule products-ban-(.*)-cat-(.*)\.html$ products.php?ban=$1&cat=$2


In the meantime I'll try what you suggested.
servantofgod
 
Posts: 22
Joined: Wed Oct 01, 2008 8:14 am
Location: Chicago

Postby servantofgod » Wed Oct 01, 2008 3:21 pm

Same result. Take a look at http://www.whatsshopping.com/index2.php

and take a look at whatsshopping.com/index.php (what it is supposed to look like)
servantofgod
 
Posts: 22
Joined: Wed Oct 01, 2008 8:14 am
Location: Chicago

Next

Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 30 guests

cron