943,746 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 2108
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Jan 22nd, 2009
0

URL ReWriting Problem?

Expand Post »
Hello there...

Any body help me to fix this problem regarding .htaccess

I have written this code to convert my url from .php to .html
PHP Syntax (Toggle Plain Text)
  1. RewriteEngine on
  2. RewriteRule shopping/leftproducts/([^/]+).html$ /shopping/leftproducts.php?c_id=$1 [L]
but this couldn't work for me...
i coundn't find where the problem occurs..

My url is like :
PHP Syntax (Toggle Plain Text)
  1. www.something.com/shopping/leftproducts.php?c_id=5

please solve my problem

Thanks In Advance
Shanti.
Similar Threads
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Jan 22nd, 2009
-1

Re: URL ReWriting Problem?

hello there...
please help on this.....
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Jan 26th, 2009
0

Re: URL ReWriting Problem?

hello..
anybody please help on this...
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Jan 26th, 2009
0

Re: URL ReWriting Problem?

OK then,
Try this:
PHP Syntax (Toggle Plain Text)
  1. RewriteEngine on
  2. RewriteRule ^shopping/leftproducts/([A-Za-z0-9]).html$ /shopping/leftproducts.php?c_id=$1 [L, QSA]
I will explain the bits of this for you
1stly you need to put the ^ charictar at the start of the string to redirect not just the wildcard

2ndly you should realy just set your variable section to a selection of leters, the way you had it if anyone was smart enough they could enter something like:
PHP Syntax (Toggle Plain Text)
  1. /shopping/leftproducts/C:/private_stuff/mybankdetails.doc
And pull up all your lovely private information. The way it is set up there it will redirect
PHP Syntax (Toggle Plain Text)
  1. shopping/leftproducts/page.html,
  2. shopping/leftproducts/bob.html,
  3. shopping/leftproducts/margret.html
But not
PHP Syntax (Toggle Plain Text)
  1. shopping/leftproducts/bob/dog/smily_face.html

I have also added the QSA flag wich is query string append (Or ammend or something ) so
PHP Syntax (Toggle Plain Text)
  1. shopping/leftproducts/page.html?Do=Make a cup of tea
would call
PHP Syntax (Toggle Plain Text)
  1. /shopping/leftproducts.php?c_id=page&Do=Make a cup of tea
Any more probs just say (I havent tested this so not 100% sure it will work)
Regards,
Sam RUdge
Reputation Points: 26
Solved Threads: 31
Posting Whiz
samarudge is offline Offline
354 posts
since May 2008
Jan 27th, 2009
0

Re: URL ReWriting Problem?

very very thanks for your input....

I got this error:
PHP Syntax (Toggle Plain Text)
  1. 500 Internal Server Error
  2.  
  3. The request was not completed. The server met an unexpected condition.
  4.  
  5. something/mysite/shopping/leftproducts.php?c_id=5 (port 80)
  6.  
  7. Please forward this error screen to 74.53.25.162's WebMaster.
  8.  

im my site i have a folder like shopping..and my leftproducts.php is in shopping folder..but index page is our side of shopping folder..
then where should i placed this .htaccees file....

thank again
waiting for your reply...
Last edited by Shanti C; Jan 27th, 2009 at 3:14 am.
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Jan 27th, 2009
0

Re: URL ReWriting Problem?

.htaccess files can go in any directory but if you are putting your rewrites in a .htaccess you should have it in the topmost directory. However you can put it anywhere you like as long as the links are relative E.G. you might be better off changing your rewrite rule to
PHP Syntax (Toggle Plain Text)
  1. RewriteEngine on
  2. RewriteRule ^leftproducts/([A-Za-z0-9]).html$ leftproducts.php?c_id=$1 [L, QSA]
Now place your .htaccess file in the shopping directory.
I am presuming you access /shopping/ from
http://yoursite.com/shopping/
so you should get the page at
http://yoursite.com/shopping/leftproducts/page.html
Hope this helps
Sam Rudge
Reputation Points: 26
Solved Threads: 31
Posting Whiz
samarudge is offline Offline
354 posts
since May 2008
Jan 27th, 2009
0

Re: URL ReWriting Problem?

thanks again for your reply...
i got the same error after i tried as you directed...

please give more inputs on this..
thank you..
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Jan 27th, 2009
1

Re: URL ReWriting Problem?

have you determined that mod_rewrite is enabled in your server
500 Internal server error often means the module is not compiled in
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
Jan 27th, 2009
0

Re: URL ReWriting Problem?

thanks bob...
how to know that is enabled or not...
if not how to enable it????
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Jan 27th, 2009
1

Re: URL ReWriting Problem?

Hmm, it dont look like a missing module in apache as the error outputs the redirect URL
PHP Syntax (Toggle Plain Text)
  1. something/mysite/shopping/leftproducts.php?c_id=5
Try asking your webhost but other than that im stumped, sorry
Reputation Points: 26
Solved Threads: 31
Posting Whiz
samarudge is offline Offline
354 posts
since May 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: how to save and retrieve an image using mysql and php
Next Thread in PHP Forum Timeline: spelling mistakes ?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC