B
B
bismoney2015-02-28 21:39:50
Drupal
bismoney, 2015-02-28 21:39:50

How to fix Rewrite?

For a week now I can not overcome the problem, already really all the forces are gone.
I describe my trouble...
I moved from DLE to Drupal, transferred all the information and so on.
There are more than 5000 pages, page addresses have changed, but very simply, for example...
on DLE it was like this
/section/584_ya_vottakaya_stranica.html
Where 584 is the news ID in DLE.
That is, there is no such thing in Drupal and in Drupal the url looks like this
/section/ya_vottakaya_stranica.html
And everything would be cool, we write the usual Rewrite rule for this

RewriteRule ^(razdel\/)([0-9]+-)([-a-z0-9]*).html$ /$1$3.html [R=301,L]

Which redirects
C /razdel/584_ya_vottakaya_stranica.html
TO /razdel/ya_vottakaya_stranica.html
And it works great BUT there was a problem!
There is such news, for example
, 12 years old gave him
Ie url in DLE, he has
ID + news name
543_12_let_dali_emy.html
And here the problem is born!
The Rewrite rule checks the url and sees
543_12_let_dali_emy.html Cuts off 543_
from it and redirects 301
And then sees
12_let_dali_emy.html in the url
And again cuts off 12_
And 12 in our case is already the title of the news!
The problem is that he reads the rule twice.
As I just did not try to force the rule to be read 1 time, everything was unsuccessful
. Even I tried to make the nginx rule ...
Please help me, kind people !!!!
How to fix this error?
Can someone tell me the secret of how to make the rule work for the URL 1 time.
Or for example, can someone help me to do it in php.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolay Shapovalov, 2015-03-01
@zniki_ru

Try regular season

^razdel\/\d+_(\d+_)?([\d\w_]*)\.html$ /razdel/$1$2.html

I recommend reading Jeffrey Friedl "Regular Expressions"

A
Artem Khalturin, 2015-03-04
@novartem

Install the pathauto module, it allows you to create templates for URLs.
in this case the template will look something like this:
razdel/[node:nid]_[node:title].html
you can create templates for all types of nodes or for each type separately.
so you don't have to rewrite me anything.
If you have titles in Russian, don't forget to install the Transliteration module to transliterate synonyms.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question