Solved

About url rewrite

Posted on 2011-03-09
10
277 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

813 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now