1

I want to change rewrite url to remove id number, so

site/2-post.html --> Normally
site/post.html --> That I want

Is it possible ? I've checked modules php files and changed codes where was necessary, but in .htaccess couldn't unable to set. my .htaccess is here I guess there is necessarry part when I changed it some problems happend

RewriteRule ^([0-9]+)-([^/]*)\.html$ /index.php?newsid=$1&seourl=$2 [L]
tshepang
  • 12,111
  • 21
  • 91
  • 136

3 Answers3

0

I don't think what you want to achieve is possible, because the application will need to know the ID in order to do anything useful. If the only thing the browser requests is site/post.html, the server cannot magically reinvent the ID that would previously have been in the URL.

The only way this is possible is if the application can look up an article based purely on the "seourl" parameter, in which case you can simply remove the "newsid" part from the URL, leaving a rule like this:

RewriteRule ^([^/]*)\.html$ /index.php?seourl=$1 [L]

The easy way to test whether this will work is to type a URL into your browser of the form that rule would map to, so e.g. http://yoursite.example.com/index.php?seourl=some-post-that-exists

IMSoP
  • 89,526
  • 13
  • 117
  • 169
  • IMSoP, thanks to reply but seourl parameter only change seo type not relevant url construction, also i want to create url without index.php or the other parameters (such as id) i think there is no way to create this url construction – Gökhan Değirmenci May 06 '13 at 00:31
  • You can't create a URL that doesn't contain the information needed to retrieve the right content, because the URL is the only input the server gets. So you can change the way parameters are put together, and remove things which are always the same such as `index.php`, but somewhere there needs to be enough information to actually select the right post. – IMSoP May 06 '13 at 00:38
  • I see what you want to say. So is it possible by using 301 ? – Gökhan Değirmenci May 06 '13 at 00:45
  • I'm not sure how you think 301 would help. If you have too little information in the URL, a 301 can't magically add it; if you have all the information in the URL, telling the browser to try again with less information isn't going to be useful. Your web server only sees the URL the browser is currently requesting, so information that isn't in that URL has nowhere else to exist. – IMSoP May 06 '13 at 00:49
  • There are so many web sites using URL that I want, and by using 301 may be possible because of examples given in other web sites that could find the solution to solve this problem. So speaking with authority is no necessary. Thanks. – Gökhan Değirmenci May 06 '13 at 00:57
  • Like I say, **if** the PHP application can look up the appropriate news post based on its name (the `seourl=` parameter in your example rule) then it's perfectly possible to remove everything other than that from the URL. If the application **needs** the ID in order to look up a news post, then the URL must have that ID in somewhere; this is fundamentally how the web works. – IMSoP May 06 '13 at 00:59
  • I know this, and I dont know how I can do this in DLE. For this reason I wrote in title "DATALIFE ENGINE". It is no general question. Of course DLE's pages work with ID and seperating is problematic and I asked it, the other way why I am here ? Even so a lot of thanks to reply the question. – Gökhan Değirmenci May 06 '13 at 01:07
  • OK, but you made clear in your question that you thought the problem was with your Apache configuration, which it is not. Your problem is that you need to be able to access a post via `/index.php?seourl=foo`; once you have that, the Apache configuration to make it "look pretty" is easy. – IMSoP May 06 '13 at 01:10
0

this hack replace id to end of url: find this: engine/modules/show.short.php engine/modules/show.full.php

find . $row['id'] . "-" . $row['alt_name'] . ".html";

replace with: . $row['alt_name'] . "-" . $row['id'] . ".html";

put this code in .htaccess

RewriteRule ^(.*)-([0-9]+).html(/?)+$ index.php?newsid=$1&seourl=$2 [L]
RewriteRule ^([^.]+)/(.*)-([0-9]+).html(/?)+
$ index.php?newsid=$2&seourl=$3&seocat=$1 [L]
Reactor
  • 19
  • 5
0

Back in DLe 8.x this option can be modified but in 9.x and 10.x are out of luck and I fully agree with IMSoP due to DLE use ID base to generate the seourl.

Yori Smith
  • 80
  • 8