Solved

About url rewrite

Posted on 2011-03-09
10
279 Views
Last Modified: 2013-12-13
Since it is a Rewrite question not sure I should post it here:

At root level is a dir /nav_excerpts/ it contains excerpts.php
excerpts.php generates a link as follow (here on dev machine) http://localhost/member/profile.php?username=Paul
I am trying to rewrite it so it will read http://localhost/member/profile-Paul.html
Obviously the following is not working

RewriteRule ^member/profile-([a-z0-9]+)\.html$ /member/profile.php?username=$1 [L]
0
Comment
Question by:array007
  • 5
  • 5
10 Comments
 
LVL 5

Expert Comment

by:onemadeye
ID: 35086590
So.. you have this file 'excerpts.php' :
http://localhost//dir/nav_excerpts/excerpts.php

and want it to be accessible through (for example):
http://localhost/member/profile-Paul.html
0
 
LVL 1

Author Comment

by:array007
ID: 35086661
Yes that is correct (you have a little typo, after localhost //)
Thanks
0
 
LVL 5

Expert Comment

by:onemadeye
ID: 35086807
And where is the HTACCESS file located? Is it in 'dir' directory?

Also, is this link is already accessible :
http://localhost/member/profile.php?username=Paul

And last, in your htaccess file, try to replace [L] with [R] or [R,NC,L] and see if the page redirects you to a correct location.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:array007
ID: 35086885
Thanks that .htaccesss in at root level
I tried the [R,NC,L] but to no avail
0
 
LVL 5

Expert Comment

by:onemadeye
ID: 35086951
Okay...
(A) http://localhost/member/profile.php?username=Paul
(B) http://localhost/member/profile-Paul.html

If you try to open (A) on your browser, does it show the correct page?

If (A) is not accessible then I think there's no way that (B) will be accessible.
0
 
LVL 5

Expert Comment

by:onemadeye
ID: 35086970
[R,NC,L]
If you use it on htaccess as I told you, whenever you open (B) check on address bar, it should be redirects you back to (A) .. in other words the URL typed on address bar is changing to (A)
Is it ?
0
 
LVL 1

Author Comment

by:array007
ID: 35087159
A, works fine but the url is not at all rewritten
B, could not be accessed as it is not anywhere in sight
sorry for the headache!
Also before you ask, yes rewrite is on.
0
 
LVL 5

Accepted Solution

by:
onemadeye earned 500 total points
ID: 35087249
Yes I can see that (B) cannot be accessed, but check on the address bar does the URL redirects you back to (A) when you use [R,NC,L]

Try this too :
RewriteRule ^member/profile-([a-z0-9]+)\.html$ member/profile.php?username=$1 [L]

Open in new window

0
 
LVL 1

Author Comment

by:array007
ID: 35087347
Sorry, no the URL does not redirect
as is when overing the link, it still show the GET mode type URL
I will need to perform a live test on my server to see if live makes a difference.
Then I will report back
thanks
0
 
LVL 1

Author Closing Comment

by:array007
ID: 35108381
Thanks, it works on live server
don't know why it's not working on my test bed.
Anyway done!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question