Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite take out spaces?

         

brisctt

3:51 pm on Sep 22, 2011 (gmt 0)

10+ Year Member



I'm new to mod rewrite, but have figured out so far how to do what I need. one of the last things I'm looking to do is change any Spaces in the url to have Dashes. Any help would be greatly appreciated.

For example:
[domainname.com...]
[domainname.com...]

Here's what I have so far, but not sure where to proceed from here:
#
# Externally redirect client requests for old dynamic URLs to equivalent new static URLs
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /manufacturer\.php\?id=([^\ ]+)\ HTTP/
RewriteRule ^manufacturer\.php$ [domainname.com...] [R=301,L]
#
# Internally rewrite search engine friendly static URL to dynamic filepath and query
RewriteRule ^parts/([^/]*)/?$ /manufacturer.php?id=$1 [L]

g1smd

6:54 am on Sep 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This rewrite should be an additional rule that is listed ahead of all your other rules (that do the normal redirecting and rewriting that your site requires). This extra rule (likely two rules) detects requests with a space in the path or a space in the query string and rewrites the request to be handled by a specual PHP script that fixes the URL format then sends out the required 301 header and location header to make the redirect happen. I don't see anything in your rule that specifically detects spaces?
This 31 message thread spans 2 pages: 31