Jump to content

mod rewrite and custom error page redirection problem


lovesmith

Recommended Posts

my mod_rewrite module is turned on in the configuration file.

 

I m trying to use mod rewrite in my local machine

i have a folder urlrewriting and inside it all the files and .htaccess files exist

i have following code in httaccess file.

 

Options +FollowSymLinks
RewriteEngine on
RewriteBase /urlrewriting/
RewriteRule productinfo/proid/(.*)/ productinfo.php?proid=$1

all i want to do is rewrite http://localhost/urlrewriting/productinfo.php?proid=12 to

http://localhost/urlrewriting/productinfo/proid/12/

 

But it didnt worked.

I have test.php where there is a link like this

 

<a href="productinfo.php?proid=12">Product 12</a>

the link still goes to http://localhost/urlrewriting/productinfo.php?proid=12

 

Where i went wrong? Somebody help me

 

And even custome error page is not working as well

 

i have code in same htaccess file

ErrorDocument 404 /err/404.php

i have folder "err" and the page as well

 

it didnt worked...anybody tell me how to make these work?

Thanks a ton in advance

lovesmith

 

 

my mod_rewrite module is turned on in the configuration file.

 

I m trying to use mod rewrite in my local machine

i have a folder urlrewriting and inside it all the files and .htaccess files exist

i have following code in httaccess file.

 

Options +FollowSymLinks
RewriteEngine on
RewriteBase /urlrewriting/
RewriteRule productinfo/proid/(.*)/ productinfo.php?proid=$1

all i want to do is rewrite http://localhost/urlrewriting/productinfo.php?proid=12 to

http://localhost/urlrewriting/productinfo/proid/12/

 

But it didnt worked.

I have test.php where there is a link like this

 

<a href="productinfo.php?proid=12">Product 12</a>

the link still goes to http://localhost/urlrewriting/productinfo.php?proid=12

 

Where i went wrong? Somebody help me

I think you've misunderstood how mod_rewrite works. It does not make links look in another way once they're output but it rewrites the URLs which are requested. I.e. if the user enters http://localhost/urlrewriting/productinfo/proid/12/ into the address bar it would have worked as had he typed http://localhost/urlrewriting/productinfo.php?proid=12.

 

And even custome error page is not working as well

 

i have code in same htaccess file

ErrorDocument 404 /err/404.php

i have folder "err" and the page as well

 

it didnt worked...anybody tell me how to make these work?

How exactly doesn't it work? If you go to a page which you know doesn't exist you should get the /err/404.php page instead. Doesn't that work?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.