|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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] |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
>> 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] |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > want to use modrewrite and .htaccess for simpler urls |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|