Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite - help please

         

prknives

2:32 am on Apr 3, 2004 (gmt 0)

10+ Year Member



Well, im sure you all love to hear these help stories and im one of them. I dont understand the whole concept of mod_rewrite either. But, here's what I'd like to happen.

I've got a url like this:

[example.com...]

how would i edit the .htaccess to make it into:

[example.com...]

I've also got another question, If i have this set up, will google index my pages better? I know with php, google doesnt recognize some of the urls, but will it reconize this?

Thanks a lot for any help you can give me.

- Craig Lichtenberg

prknives

10:41 pm on Apr 5, 2004 (gmt 0)

10+ Year Member



Well, i got that sorted out. But, I also want to do another mod_rewrite, and I cant do them at the same time. =/

Here's my .htaccess:
RewriteEngine On
RewriteRule reviews/([0-9]+) modules.php?module=reviews&id=$1
RewriteRule imports/([0-9]+) modules.php?module=imports&id=$1
RewriteRule versus/([0-9]+) modules.php?module=versus&id=$1

RewriteRule index.html index.php

RewriteCond %{REQUEST_URI} /(reviews¦imports¦content)*
RewriteRule ^(reviews¦news)/images/(.*).(gif¦jpg)$ images/$2.$3

RewriteCond %{REQUEST_URI} /(reviews¦imports¦content)*
RewriteRule ^(reviews¦news)/xtra/(.*).(gif¦jpg)$ xtra/$2.$3

RewriteCond %{REQUEST_URI} /(reviews¦imports¦content)*
RewriteRule ^(reviews¦news)/(.*).(css)$ $2.$3

#After I add the next commands, it doesnt work.
#The image directories are wrong now, and Im not sure
#what to do.

RewriteCond %{REQUEST_URI} v3/SubmitReviews*
RewriteRule SubmitReviews modules.php?module=SubmitReviews

RewriteCond %{REQUEST_URI} v3/reviews*
RewriteRule reviews modules.php?module=reviews
RewriteCond %{REQUEST_URI} reviews*
RewriteRule reviews/(.*) modules.php?module=reviews&id=$1

RewriteCond %{REQUEST_URI} v3/imports*
RewriteRule imports modules.php?module=imports
RewriteCond %{REQUEST_URI} imports*
RewriteRule imports/(.*) modules.php?module=imports&id=$1

anyone =/

jdMorgan

10:53 pm on Apr 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



prknives,

Welcome to WebmasterWorld [webmasterworld.com]!

A few comments:

If you do not want mod_rewrite to continue rewriting the URL using all of your rules, use an [L] flag at the end of the RewriteRule line.

If you want to match precise strings, prefixes, or suffixes, anchor your patterns (See regex reference below).

The "*" character has special meaning to mod_rewrite, which uses regular expressions; It means "One or more of the preceding character, group, or parenthesized subpattern."

A review of the Apache RewriteRule documentation [httpd.apache.org] and this Regular Expressions tutorial [etext.lib.virginia.edu] will probably help if you're getting unexpected results.

Jim