Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can !
Moderator: General Moderators
Luke
The Ninja Space Mod
Posts: 6424 Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA
Post
by Luke » Tue Nov 28, 2006 4:59 pm
I need a regex book badly... but for now, can somebody help me out with this rule?
I'm trying to allow urls like /page/PAGECODE or /page/PAGECODE?querystringkey=querystringval&morekeys=morevalues
I thought this rule would work, but it doesn't seem to be grabbing the query string.
Code: Select all
RewriteCond %{REQUEST_URI} ^/page/(.*)?(.*) [NC]
RewriteRule (.*) /merchant2/merchant.mvc?Store_Code=BS&Screen=%1&%2 [L]
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Nov 28, 2006 5:11 pm
? is a metacharacter that I recall in POSIX.
Untested:
Code: Select all
RewriteCond %{REQUEST_URI} ^/page/(.*)$ [NC]
RewriteRule ^/page/(.*)$ /merchant2/merchant.mvc?Store_Code=BS&Screen=$1 [L,QSA]
Luke
The Ninja Space Mod
Posts: 6424 Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA
Post
by Luke » Tue Nov 28, 2006 5:29 pm
hmm... nope
Isn't that $ supposed to be a %
I tried switching it, but it still didn't work... gives me a 404 page (meaning it's not being rewritten correctly)
redmonkey
Forum Regular
Posts: 836 Joined: Thu Dec 18, 2003 3:58 pm
Post
by redmonkey » Tue Nov 28, 2006 7:02 pm
mod_rewrite supports logging, turn it on and set an appropriate log level for debugging your rewrite rules.
Buddha443556
Forum Regular
Posts: 873 Joined: Fri Mar 19, 2004 1:51 pm
Post
by Buddha443556 » Tue Nov 28, 2006 7:55 pm
Isn't %{QUERY_STRING} needed here somewhere?
Luke
The Ninja Space Mod
Posts: 6424 Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA
Post
by Luke » Wed Nov 29, 2006 10:04 am
I don't know. Anybody know a really good mod_rewrite tutorial/reference?
Fractal
Forum Commoner
Posts: 54 Joined: Tue Aug 16, 2005 1:28 pm
Post
by Fractal » Wed Nov 29, 2006 7:31 pm
I just use
RewriteEngine On
RewriteRule ^(file1|file2)(/.*)?$ $1.php$2
and update it statically. I used to have it look similar to yours until recently o_O
Last edited by
Fractal on Sat Jan 20, 2007 5:43 am, edited 1 time in total.
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Wed Nov 29, 2006 7:39 pm
There are few useful tutorials posted in the 'Useful Resources' sticky in Apache, IIS and Servers. I think you are going to want to put some more in there though. This is one that I just got working a few days ago...
Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [S=1]
RewriteRule ^([A-Za-z0-9-_]+)/APPNAME-VISIT-ID-([A-Za-z0-9]+)/?$ /index.php?p=$1&sid=$2 [QSA,L]
RewriteRule ^([A-Za-z0-9-_]+)/?$ /index.php?p=$1 [QSA,L]
RewriteRule ^([A-za-z0-9-_]+)/activate_([0-9]+)/activate_with_([A-za-z0-9]+)/?$ /index.php?p=activate_user&user=$2&activation_code=$3 [QSA,L]
</IfModule>
I am almost certain this will not help you, but it might make you want to go out for pizza and beer.