Rewrite http://www.ex.com/folder/113-article to http://ex.com/article

I have been trying for days to get this rewrite to work, searching everywhere on the net. Can anyone help me remove the numerals from the title of the page.

rewrite http://www.ex.com/folder/113-article to http://ex.com/article

ab,

Removing the digits is easy - serving the result in a meaningful way is not.

May I assume that you want to (a) enforce www on the domain and (b) you want to redirect article to folder/113-article. As a reminder, YOU create the new format and YOU create the mod_rewrite to redirect from your new format to something Apache can serve. Can Apache serve article? Is it a directory?

I think that the best thing is for you to read a bit about mod_rewrite (start with the link in my signature) then come back with specific questions.

Regards,

DK

Thanks for the pointer to your blog, it was indeed useful, i feel a little more confident, however i am still getting 500 errors when i engage this line of the rewrite:

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

Can you advise me where i am going wrong?

ab,

PLEASE wrap your code in [noparse]

...

[/noparse] tags as that preserves the code when quoting for a reply.

The problem I see is that your test URL cannot be matched by your regex:

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

First, Rewrite should give you a 500 error as there is no such directive.

Second, component and content will match properly.

Third, ([0-9_]+) will not match 67-todays-news as there are no -'s or lowercase letters in your regex (replace with ([-0-9a-z]+) ).

Fourth, ditto (use ([0-9]±([-a-z]+)) ).

Please remember “Specificity,” i.e., verbalize your goal, part by part, then code to meet that specification. In other words, please go back to the tutorial and look at the development of regex.

Regards,

DK

Many thanks for your prompt and clear respons. I will look at this this evening and come back to you.

Again thanks for your help, it’s much appreciated

Chris