Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 11th, 2001, 10:02 AM
georgie99999 georgie99999 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 3 georgie99999 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

hi. i am querying a mysql database using php4 to build my pages. Example can be seen here
URL


I want simpler urls and want to translate the url /article/foo into the url /showme.php?id=foo.

I don't mind if the user sees the translated url or not.

I have access to .htaccess but not httpd.conf and my pages are served with Apache 1.3 on a Red Hat server

I have tried a number of options in my .htaccess file, the closest (I think) to working is:

RewriteEngine on
Options FollowSymLinks
RewriteRule ^/samizdat/article/(.*)$ /samizdat/showme\.php?id=$1 [S=1]

I have read and reread the Apache 1.3 rewriting guide at URL but am still no clearer. Am I just getting syntax wrong or am I in compltetly the wrong ball park?

Regards

george

Reply With Quote
  #2  
Old March 11th, 2001, 11:25 AM
georgie99999 georgie99999 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 3 georgie99999 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hello.

I have found the marvellous tutorial at URL and am working my way through it

and I have successfully used the following:

# replace anything/article/id with full.path.to.fiddlesticks/showme.php?id


RewriteRule ^(.*?)article/(.*)$ URL


#was messing up images, opt them out
RewriteRule ^(.*?)article/images/(.*?)$ URL


I used the fully qualified domain for the rewrite because otherwise the header was being sent again..with much messiness! I opted /images/ out of the rewrite, again, as this caused problems.

this may not be a perfect solution - any comments are appreciated, but it does work.




hurrah

george

[Edited by georgie99999 on 03-11-2001 at 01:28 PM]

Reply With Quote
  #3  
Old March 11th, 2001, 07:44 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You should search first as there are more examples you can take a look from. Try to search with RewriteEngine as keyword and my username and under Apache forum.

>> # replace anything/article/id with full.path.to.fiddlesticks/showme.php?id

That is not search engine-friendly. Anyhow, you'll be looking at external redirect. Apache doc also has something about this. Please try first, if you still can't get it to work, come back and somebody or I will post you the rules.


Reply With Quote
  #4  
Old March 11th, 2001, 08:23 PM
georgie99999 georgie99999 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 3 georgie99999 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hello FreeBSD, thank you for your help.

is this any better?


RewriteEngine on
RewriteRule ^(.+)/article/$ showme.php?$1 [T=application/x-httpd-php]

The version I quote below did work, but you say it's not search engine friendly. I thought removing the ? from the urls was the way to do make it so


A further query, you say

>> Anyhow, you'll be looking at external redirect


why do I want an external redirect?

Thanks for help, you did it in one line when i had 2.

cheers



Reply With Quote
  #5  
Old March 11th, 2001, 10:49 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> is this any better?
>> RewriteEngine on
>> RewriteRule ^(.+)/article/$ showme.php?$1 [T=application/x-httpd-php]

This is internal redirect and that's not what you asked for. Further, it won't work since it internal redirects somethng that doesn't match to $1. Specifically /article is the top level of the relative URL http://www.fiddlesticks.com/article/.

Try this at http://www.fiddlesticks.com/.htaccess

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/article/images/*
RewriteRule ^(.*) - [L]
RewriteRule ^/article/(.+) http://www.fiddlesticks.com/samizdat/showme.php?id=$1 [R,L]

This only external redirects anything that matches the relative URL of /article/blahblah to http://www.fiddlesticks.com/samizda...hp?id=blahblah. Your showme.php itself needs to know how to interpret what to do with $QUERY_STRING of blahblah.

>> why do I want an external redirect?

You don't seem to know the difference, let me explain. You said you want visitors to see http://www.fiddlesticks.com/samizda...hp?id=something in the browser location bar but they really requested something different (http://www.fiddlesticks.com/article/something). An exernal redirect is to display the content of http://www.fiddlesticks.com/samizda...hp?id=something and this URL is to be stay in the location bar as your request.
For internal redirection, the browser location bar doesn't change. That is, visitors requesting http://www.fiddlesticks.com/article/something will be seeing http://www.fiddlesticks.com/article/something at the location bar. The internal redirection takes place internally, visitors can't even tell if there is a redirection at all.

If you check out this thread -> http://forums.devshed.com/showthrea...9203&forumid=15, that is exactly the other way around.
People requesting http://www.fiddlesticks.com/article.php?page=blahblah, mod_rewrite then sends the QUERY_STRING (page=blahblah), Apache then launch a document on the file system /path/to/file.any_extension, the [T=application/x-httpd-php] tells Apache to treat file.any_extension as a PHP script. Your script (file.any_extension) then take the page=blahblah and open up the /server/path/to/something accordingly and display the exact content of /server/path/to/something, up to this point, all processes are being done internally, next, Apache sends http://www.fiddlesticks.com/something back for display and the location bar stays as http://www.fiddlesticks.com/something.

[Edited by freebsd on 03-11-2001 at 09:55 PM]

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > want to use modrewrite and .htaccess for simpler urls


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT