iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-24-2007, 08:53 AM
pagetta's Avatar
WebProWorld Veteran
 
Join Date: Nov 2004
Location: UK
Posts: 509
pagetta RepRank 2
Default .htaccess rewrite query

We have an awful lot of pages that use php variables to parse and i would like to rewrite these so that 1. they look cleaner and 2. users can't see how we're doing stuff or where it is.

so for example if you want to download a whitepaper you click a link that says
'../resources/download.php?file=whitepapder.pdf" I would like this to be seen as ../resources/download/whitepaper.pdf

and when the file is obtained and openend i do not want the url to reveal its exact location but to say www.mysite.com/resource

and also when you don't fill in a complete form it returns that page with a messgae so the url reads:
http://www.mysite.com/resources/down...%20your%20name
Obviously it would be nice if this could just say :
../resources/download/whitepaper.pdf

i know this is 3 questions in one and i realise there are a million tutorials across the net but I am not 100% sure which applies to each of my needs and though perhaps you guys could be of some help!

I can see in theory how this will work its just finding the exact code to use as i have little htaccess experience.

thank you so much
Reply With Quote
  #2 (permalink)  
Old 04-25-2007, 07:20 PM
TrafficProducer's Avatar
WebProWorld 1,000+ Club
 
Join Date: Jul 2003
Location: United Kingdom
Posts: 1,642
TrafficProducer RepRank 3TrafficProducer RepRank 3TrafficProducer RepRank 3
Default Mod Rewrite. & .htaccess

Mod Rewrite. & .htaccess links. Not sure if this will help you, I hope so, here's some links:-

Apache open-source software and Apache Servers. Mod Rewrite.

.htaccess Files and .htaccess Help. How use to .htaccess
Reply With Quote
  #3 (permalink)  
Old 04-25-2007, 07:49 PM
WebProWorld New Member
 
Join Date: Nov 2004
Location: off the grid
Posts: 16
Kristos RepRank 0
Default Sometimes the best Self Tutorial is an Actual Book

I bought their book on "creating a database driven site using PHP and MYSQL" and it helped me alot. I refer back to it from time to time.
Sitepoint has a book out called:
"mod_rewrite: A Beginner's Guide to URL Rewriting"
Here is a link to it : http://www.sitepoint.com/article/guide-url-rewriting

they'll even give you four chapters for free to see if it helps you.

Hope this helps
Kristos
__________________
Prayer Requests
Reply With Quote
  #4 (permalink)  
Old 04-26-2007, 03:27 AM
WebProWorld Member
 
Join Date: Jan 2007
Location: India
Posts: 38
ddwebguru RepRank 0
Default

Hi
first of all your server should be linux not windows, mod rewrite works in only linux or apache server.
this is a easy method you can try to find it in google , here are 2 links hope will help you.
http://www.webforgers.net/mod-rewrite/#mod_rewrite
http://www.webforgers.net/mod-rewrit...ite-syntax.php
Reply With Quote
  #5 (permalink)  
Old 04-26-2007, 03:30 AM
katropa's Avatar
WebProWorld Member
 
Join Date: Oct 2005
Location: South Africa
Posts: 40
katropa RepRank 0
Default

# from: /resources/download/whitepaper.pdf
# to: /resources/download.php?file=whitepaper.pdf


Add the following code to your .htaccess file

ON YOUR LOCAL SERVER (http://localhost/...)
Code:
RewriteEngine On 
RewriteBase /resources/
RewriteRule download/(.*).pdf       download.php?file=$1.pdf [L]
ON YOUR WEB SERVER (http://www.mysite.com/...)
Code:
RewriteEngine On 
RewriteRule ^resources/download/(.*).pdf       resources/download.php?file=$1.pdf [L]
Your download link would look like this (HTML):
Code:
White Paper
You can start with the above.
Hope it works.
Rainer
Reply With Quote
  #6 (permalink)  
Old 04-26-2007, 06:42 AM
WebProWorld New Member
 
Join Date: Nov 2005
Posts: 9
tim2005 RepRank 0
Default

In addition to previous post.

If you are going to use URL like:
http://www.mysite.com/resources/down...%20your%20name

You may want to transform it to:
http://www.mysite.com/resources/down...%20your%20name

So, you need additional rule in your .htaccess for such URLs:
Code:
RewriteRule ^resources/download/(.*).pdf ?message=(.*)      resources/download.php?file=$1.pdf&message=$2 [L]
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 12:30 PM.



Search Engine Optimization by vBSEO 3.3.0