Printer Friendly Version
Email this thread to a friend
|
Featured Web Site Template |
|
There are 0 guests and 1 members in the forums right now.
Reflects user activity within the last 5 minutes
|
|
| Member |
Message |
gericsb
Joined: Jan 16, 2001
# Posts: 299
|
Posted: 03/06/2007 03:23 pm
Hi All,
Can somebody please explain to me how to modify or add to my htaccess file below a rule that will replace spaces in my URLs with hyphens (dashes). My URLs are of the form:
mydomain.com/country/artist.php?name=firstname%20lastname and I want the rwrite to rewrite them to:
mydomain.com/country/firstname-lastname.html
My rewrites are working as long as I do NOT include a space betwen the first name and last name, but I need to handle spaces. In fact I would like EVERY space encountered in the name to be replaced with a '-'. PLease help!
RewriteEngine On
RewriteCond %{HTTP_HOST} ^concerts.ws$ [NC]
RewriteRule ^/?(.*)$ http://www.concerts.ws/$1 [R=301,L]
RewriteRule ^/?country/([a-zA-Z0-9-]+).html$ country/artist.php?name=$1 [L]
|
 |
gericsb
Joined: Jan 16, 2001
# Posts: 299
|
Posted: 03/06/2007 04:46 pm
I really need help with thiw--Ive been searching Google for 2 days and none of the solutions I found explains how to do this--I am also really new at this BUT there must be a way to ad something to my htaccess file to replace every space found in my URL with a hyphen--isn't there?
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10284
|
Posted: 03/07/2007 03:36 am
Are there always the same number of spaces in the URLs? This is a crucial point.
Whatever you do, you must make sure that any rewrite or redirect is done in one step. That is, you must NOT redirect for the correct filename and then issue a separate redirect from non-www to www. You must do everything in one redirect.
A redirection chain will cause a LOT of problems.
|
 |
gericsb
Joined: Jan 16, 2001
# Posts: 299
|
Posted: 03/07/2007 06:14 am
gi--No there are not ALWAYS the same number of spaces, for instance my URLs include the names of musical artists so the artist could be 'Sting' (no spaces)
'Carrie Underwood' (1 space)
'The Red Hot Chili Peppers' (4 spaces)
etc.
The number of spaces varies
Also I do not mind having a unique line in my htaccessto match each number of spaces
Also, I think I may have to modify ([a-zA-Z0-9-]+) to be
(-a-zA-Z0-9 ]+) or something like that and create rules that have 1 variable (no space), 2 variables (2 space) etc or something like that. I will *probably* never have more than 5 spaces in any musical artists name.
My problem is I am not sure how to EXACTLY add the rewrite rules to account for each of these different URLs and get the '-' into the URL wherever there is a space.
|
 |
Curt
Joined: Eons Ago
# Posts: 3717
|
Posted: 03/07/2007 07:19 am
Why are you using spaces in your file names in the first place? Use "www.site.com/The.Red.Hot.Chili.Peppers.htm" instead of "www.site.com/The Red Hot Chili Peppers.htm".
|
 |
You are not permitted to post messages in this forum or topic, because of one or more of the following reasons:
- You have not yet logged in, or registered properly as a member
- You are a member, but no longer have posting rights.
- This is a private forum, for which you do not have permissions.
If you are a recent member, it's possible that you simply have not yet confirmed your account. Please
check your email for a message entitled 'JimWorld Forums: Confirm Your Account' and follow the instructions
contained within.
If you cannot find this message, click here to Re-Send it.
|
If you are still experiencing problem, please read the
Login Assistance
Article for some advice on what may be causing your login not to work properly.
|
Switch to Advanced Editor and ...
Create a New Topic
or Reply to this Thread
|
|