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

 

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.