Need help with setting up the url rewrite

New to mod_rewrite? This is a good place to start.

uknown column

Postby revo » Thu Jun 11, 2009 4:38 pm

When I set it like this:


WHERE sellers.title = Sears

Then I get an error saying

unknown column 'sears' in 'where clause'


I just took out the get array from this query so I can just test it more directly. I do have title as a new column in my table and I placed Sears as one value in that column, so I don't know why it says this error.

by the way I am using Dreamweaver to do this..
and thanks for your free help
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Fri Jun 12, 2009 8:44 am

It needs quoting
Code: Select all
WHERE sellers.title = "Sears"


If you have more problems please post the whole query and some of the relevant PHP.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

from your experience

Postby revo » Fri Jun 12, 2009 9:18 am

It seems like lots more complex work compared to option 1 on here with the httpd.conf file. With option 1 I can leave my ID's and make a list of ID's matching the store names right?

viewtopic.php?p=11041#11041

If I look for a hosting that will give me access to httpd.conf file, will I get the same results on my urls as I am looking for such as

mysite.com/coupons/Sears

and will they be treated the same by search engines when they display it on the search results. Once I have made this in both the httpd.conf and .htaccess will the href= links read as the ID number or will they read as the store name? I guess I don't know if the httpd.conf and .htaccess will run first then my site will run or how its done.

Thanks again!
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Sat Jun 13, 2009 2:27 pm

It seems like lots more complex work compared to option 1 on here with the httpd.conf file.

You will still need to create and update the list.

With option 1 I can leave my ID's and make a list of ID's matching the store names right?

With Option 1 you will not have to change the script (unless you automate the list updating).

If I look for a hosting that will give me access to httpd.conf file, will I get the same results on my urls as I am looking for such as

mysite.com/coupons/Sears

You can have /coupons/Sears using the httpd.conf file.

will they be treated the same by search engines when they display it on the search results.

How mod_rewrite does it will not matter. You might want to read Google: Dynamic URLs vs. static URLs, though.

Once I have made this in both the httpd.conf and .htaccess will the href= links read as the ID number or will they read as the store name?

With all mod_rewrite, the href="" attribute must be the URL you want in the address bar of the browser (ie. href="/coupons/Sears").
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

href links when hovering with mouse

Postby revo » Sun Jun 14, 2009 8:00 pm

So as I am understanding, if I keep the ID's then my text links in my website will reflect the ID (ie: mysite.com/coupons.php?list=143) when people hover their mouse over the link, even if I have the httpd.conf and .htaccess files setup? It is just the url that will say what I want it to say.


But if I choose option 1, change my href text links to store name instead of ID then it will show (ie: mysite.com/coupons.php?list=sears) when they hover over it? or this is the part I am confused on, will it show what I have setup in my .htaccess such that when people hover over the link I would like to show (ie: mysite.com/coupons/list/sears) ?
I know the url will show this, but will the hovering with their mouse also show the same thing, even though I have it setup as dynamic like this example ( mysite.com/coupons.php?list=sears).

Thanks
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Mon Jun 15, 2009 11:43 am

Mod_rewrite works on incoming requests only. You must edit your script so the URL outputted is the URL you want in the address bar of the browser. In other words whatever you do you must change
Code: Select all
<a href="/coupons.php?list=143">

to
Code: Select all
<a href="/coupons/list/Sears">

or whatever you want the visitor to see. Everything else happens inside Apache and does not affect the user.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

local wamp

Postby revo » Wed Jun 17, 2009 9:16 pm

Hi,
thanks again, I am trying to get this to work in my local wamp server first and I'm getting error:

--------------------------
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
---------------------------

I pulled out the # from mod_rewrite line in the httpd.conf file like in your instructions on how to enable modrewrite and here is what I have in my .htaccess

<Directory /wamp/www/mylocalsite/>
Options +FollowSymLinks
AllowOverride All


Options +FollowSymLinks
RewriteEngine on
RewriteRule stores/deals/(.*)/ deal.php?name=$1
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Thu Jun 18, 2009 11:17 am

What does your error log say is causing the error?
You could try putting the mod_rewrite in a .htaccess file (/wamp/www/mylocalsite/.htaccess) instead of the <Directory>.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

error log

Postby revo » Thu Jun 18, 2009 3:08 pm

Here is what the error log says:

[Thu Jun 18 17:57:47 2009] [alert] [client 127.0.0.1] C:/wamp/www/mylocalsite/.htaccess:
C:/wamp/www/mylocalsite/.htaccess:11: <Directory> was not closed.
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Fri Jun 19, 2009 10:15 am

It should be
Code: Select all
<Directory /wamp/www/mylocalsite/>
  Options +FollowSymLinks
  AllowOverride All

  Options +FollowSymLinks

  RewriteEngine On

  RewriteRule ^stores/deals/([^/]+)/?$ /deal.php?name=$1 [QSA,L]
</Directory>

(Ending with </Directory>.)
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

PreviousNext

Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 13 guests

cron