Forum Moderators: phranque

Message Too Old, No Replies

rewrite to remove numbers in urls

url rewrite to remove numbers

         

Armyboy1066

5:56 pm on Nov 30, 2010 (gmt 0)

10+ Year Member



I need to rewrite

this
[mysite.com...]

to this

[mysite.com...]

g1smd

7:09 pm on Nov 30, 2010 (gmt 0)

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



What have you tried so far?

There are close to ten thousand previous threads that you can use for inspiration.

Armyboy1066

8:27 pm on Nov 30, 2010 (gmt 0)

10+ Year Member



I have tried many and been searching the web plus on this website. Don't seem to get it quite right:

RewriteRule ^component/content/([^/\.]+)/([^/\.]+)/?$ /$2 [L]

Armyboy1066

5:51 pm on Dec 1, 2010 (gmt 0)

10+ Year Member



I have also tried Rewrite ^component/content/([0-9_]+)/([0-9_]+)([a-zA-Z]+)$ /$3

Basically i have change to different SEF program which drops the folder names and also removes the numbers from the folder and title:

So a user clicking on a google link:

http://www.example.com/component/content/67-todays-news/181-news-story

sends this to the server:

http://www.example.com/news-story

jdMorgan

1:00 am on Dec 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A user clicking on the google link "http://www.example.com/component/content/67-todays-news/181-news-story" sends exactly "http://www.example.com/component/content/67-todays-news/181-news-story" to your server.

So what is the filepath that you need to use (inside the server) to fetch and serve that content? I would think that the filepath (possibly with a query string) would have to indicate which article is to be served...

On the other hand, if you are actually intending to use http://www.example.com/news-story as the linked URL, and want to serve
the content of /component/content/67-todays-news/181-news-story, then that won't work, as there is no way for mod_rewrite or the server to "know" which article is desired, unless you hard-code the "67" and the "181," and then change your code daily or hourly -- whenever the article to be associated with that URL changes.

The bottom line is that you can't map one URL to many filepaths, and you likely don't want to serve the same content for multiple requested URLs. So it would probably be a good thing to back up and describe what it is (from a practical/functional standpoint) that you are trying to accomplish.

Jim