hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : mod_rewrite for dynamic sites to appear static...
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

mod_rewrite for dynamic sites to appear static...

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 04-18-2003, 12:32 AM
digitsix digitsix is offline
Newbie
 
Join Date: Sep 2002
Posts: 13

mod_rewrite for dynamic sites to appear static...


Im looking for someone that knows mod_rewrite to tell me how I could go about getting a url that is, right now like so...

http://www.domain.com/catalog.php?c=3&p=123&id=3

to something like...

http://www.domain.com/catalog/c/3/p/123/id/3.html

I know it can be done, but im lost at how to do this, I already read the mod_rewrite docs and I'm still lost....

someone please help!

Reply With Quote


Sponsored Links
  #2  
Old 04-18-2003, 02:30 AM
digitsix digitsix is offline
Newbie
 
Join Date: Sep 2002
Posts: 13
I figured this much out:

RewriteEngine On
RewriteRule ^/test/catalog/c/([0-9]+)/p/([0-9]+)/id/([0-9]+)$ /test/catalog.php?c=$1&p=$2&id=$3

Now when i go to http://www.domain.com/test/catalog/c/3/p/134/id/3 it does in fact redirect me to catalog.php but the values for some reason are still not filled in....

any help?

Reply With Quote
  #3  
Old 04-18-2003, 03:29 AM
DarktidesNET DarktidesNET is offline
Web Hosting Master
 
Join Date: Jul 2002
Location: Missouri
Posts: 2,504
I think you have to have something like [PT] on the end.

I've really had no luck with mod_rewrite either.

__________________
What does one host say to the other? "(HostA) Want to go see a movie?" "(HostB) Sure, can your parents drive?"

I'm premium, and no, I did not have to pay $6 a month to figure that out.

Reply With Quote
Sponsored Links
  #4  
Old 04-18-2003, 12:53 PM
sponk sponk is offline
Web Hosting Guru
 
Join Date: Nov 2002
Posts: 325
try this
  • RewriteEngine On
    RewriteRule ^/test/catalog/c/([0-9]+)/p/([0-9]+)/id/([0-9]+)$ /test/catalog.php?c=$1&p=$2&id=$3 [L]

Reply With Quote
  #5  
Old 04-18-2003, 02:06 PM
digitsix digitsix is offline
Newbie
 
Join Date: Sep 2002
Posts: 13
I tried both things and neither of them worked, thanks for trying though.... anyone else have any ideas?

Reply With Quote
  #6  
Old 04-18-2003, 02:08 PM
wakkow wakkow is offline
WHT Addict
 
Join Date: Aug 2002
Location: Davis, CA
Posts: 169
I don't know mod_rewrite very well... but, i'll try anyways.. what do the two you tried do/not do? Not fill in the variables?

Reply With Quote
  #7  
Old 04-18-2003, 07:26 PM
sponk sponk is offline
Web Hosting Guru
 
Join Date: Nov 2002
Posts: 325
ok, try putting in the full URL

RewriteEngine On
RewriteRule ^/test/catalog/c/([0-9]+)/p/([0-9]+)/id/([0-9]+)$ http://www.yourdomain.com/test/catalog.php?c=$1&p=$2&id=$3 [L]

I did that for mine and it worked

Reply With Quote
  #8  
Old 04-19-2003, 12:07 AM
DarktidesNET DarktidesNET is offline
Web Hosting Master
 
Join Date: Jul 2002
Location: Missouri
Posts: 2,504
If it requires the full url, it could be an issue of a shared IP vs. Dedicated.

Just a hunch

__________________
What does one host say to the other? "(HostA) Want to go see a movie?" "(HostB) Sure, can your parents drive?"

I'm premium, and no, I did not have to pay $6 a month to figure that out.

Reply With Quote
  #9  
Old 04-19-2003, 04:59 AM
digitsix digitsix is offline
Newbie
 
Join Date: Sep 2002
Posts: 13
I tried the whole url and it still does the same thing. As it stands right now, it does in fact send me to the correct php file when i go to the fake string (the one with all the slashes)... but for some reason the c, p, and id variables are null..., I even have an echo line at the top of the catalog.php file that echos out the variables... mod_rewrite should send these variables in the environment right? I mean, that is the point of puting the $1 $2 and $3..... that would be my guess anyway... its just, im currious, how does it know what to put in the $1 $2 and the $3? I dont see how it would know to use the regex sections between the /'s as the variables....

I DONT UNDERSTAND!!!!!!!

Reply With Quote
  #10  
Old 04-19-2003, 05:02 AM
DarktidesNET DarktidesNET is offline
Web Hosting Master
 
Join Date: Jul 2002
Location: Missouri
Posts: 2,504
I'd assume it got the variables filled from the regex via back referanncing (the grouped (items)) are filled.

That's how you grab data from regular expressions by grouping them with () like a+([a-z]) you'd get the [a-z] value not the whole string.

__________________
What does one host say to the other? "(HostA) Want to go see a movie?" "(HostB) Sure, can your parents drive?"

I'm premium, and no, I did not have to pay $6 a month to figure that out.

Reply With Quote
  #11  
Old 04-19-2003, 03:30 PM
digitsix digitsix is offline
Newbie
 
Join Date: Sep 2002
Posts: 13
Well, i figured out that mod_rewrite isnt forwarding anything at all, somehow the server is just guessing i mean catalog.php when i put catalog/whatever i want.....

So i made a new rule, a very simple one...

RewriteRule ^/cata/(.*) /catalog.php?c=$1

and when i go to www.domain.com/cata/123

instead of going to catalog.php?c=123 i get a 404 not found cata no such file or directory...

This is odd to me because I have the .htaccess in the right directory, and in the server config for this directory, it has allow override set to all... If i had a gun, ida shot my self by now, so some one please, for the love of god, help me... i have no clue what the hell to do next.

Mod_rewrite IS installed...

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Vexxhost Launches cPanel-Powered Cloud Hosting Service Web Hosting News 2013-02-15 10:58:15
How the President Crashed Reddit, and How Hosts Can Help Customers Handle Traffic Spikes Web Hosting News 2012-09-10 13:48:50
Making Cloud Infrastructure Enterprise-Ready Webinars 2012-09-04 13:56:04
nginx Continues Market Share Momentum in Netcraft February Web Server Survey Web Hosting News 2012-02-09 17:29:14
Cloud Infrastructure Firm Morphlabs Launches New Technology to Improve Cloud Bursting Web Hosting News 2011-11-09 19:08:35


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?