mod rewrite being ignored

New to mod_rewrite? This is a good place to start.

mod rewrite being ignored

Postby blade912 » Tue Apr 28, 2009 10:38 am

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^displaydata\.php$ /displayimages.php[NC]

the above is being ignored

i am trying to rewrite the following
http://www.website.com/displayimages.ph ... 5U1663.JPG
to
http://website.com/displaydata.php

Any help would be appreciated as this is doing my head in
blade912
 
Posts: 6
Joined: Tue Apr 28, 2009 10:24 am

Postby richardk » Tue Apr 28, 2009 11:24 am

You are missing a space before [NC].
What happens when you visit /displaydata.php?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^displaydata\.php$ /displayimages.php [NC,QSA,L]

or possibly
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^displaydata\.php$ /displayimages.php?image=sports/CamogieNationalLeagueDivision1FinalWexfordvTipperary2009&pic=XG5U1663.JPG [NC,QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby blade912 » Wed Apr 29, 2009 4:39 am

Hi
the two sample codes are both being ignored.
when i try www.website.com/displaydata.php on the first code the picture does not appear or any information that is retrived from the database
on the second example of code when i try
www.website.com/displaydata.php the page appears as it should ,with the picture and all the information present.
blade912
 
Posts: 6
Joined: Tue Apr 28, 2009 10:24 am

Postby blade912 » Wed Apr 29, 2009 4:44 am

when i try the following it still being ignored

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^display(.*)-(.*)\.php$ /displayimages.php?image=$1&pic=$2 [NC,QSA,L]
blade912
 
Posts: 6
Joined: Tue Apr 28, 2009 10:24 am

Postby richardk » Thu Apr 30, 2009 12:58 pm

on the second example of code when i try
www.website.com/displaydata.php the page appears as it should ,with the picture and all the information present.

Then what's wrong with it?

Does this mod_rewrite test work?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby blade912 » Fri May 01, 2009 9:53 am

Its not redirecting to www.website.com/displaydata.php
you have to type in the above address to display the page
blade912
 
Posts: 6
Joined: Tue Apr 28, 2009 10:24 am

Postby richardk » Fri May 01, 2009 11:06 am

Mod_rewrite does not change the links in the pages, it only works on the incoming requests.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby blade912 » Fri May 01, 2009 2:51 pm

Redirected was probably the wrong word to use but the www.website.com/displaydata.php should be displayed instead of the longer version .
The problem i'am having is that www.website.com/displaydata.php is not being displayed
blade912
 
Posts: 6
Joined: Tue Apr 28, 2009 10:24 am

Postby richardk » Sat May 02, 2009 9:55 am

If you want the URL in the browser's address bar to be /displaydata.php you need to edit the link so that is the URL. Then mod_rewrite will intercept the request to /displaydata.php and instead send the user to /displayimages.php?...
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby blade912 » Sun May 03, 2009 7:06 am

thanks richardk
All I have to do now is to pass the variables to displaydata.php
I am trying to pass two values to the new location using the GET method What i have is the following

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^displaydata\.php$ /displayimages.php?image=$1&pic=$2%{QUERY_STRING} [NC,QSA,L]

But no values are being passed.
Any ideas on how to fix this
blade912
 
Posts: 6
Joined: Tue Apr 28, 2009 10:24 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 10 guests

cron