0

Original: http://www.mysite.my/page.php?id=688

With html func code:

{capture name=some_content assign=page_url}
{if $seo_settings.enable_mod_rewrite}{seo->makeDetailsLink p1=`$v.id` p2=`$v.title`}{else}{$live_site}/page.php?id={$v.id}{/if}
{/capture}

After enable URL friendly option.

Currently, it works like this: www.mysite.com/item-name123/page.html. However, I tried to remove the page.html$ to page$ but it still display the old link. and I need to re-write url link to www.site.com/item-name123/page in order to makes it work.

How can I transform it to be www.site.com/page/item-name123 and after click on the text will automatically find the exactly link like this: www.site.com/page/item-name123?

Current codes:

RewriteRule ^([0-9]+)-([^\/]+)?/page.html$ page.php?id=$1 [nc,qsa]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d

Updated: abc to item-name123 (for better understanding)


Full code of .htaccess

http://textuploader.com/t458

Sharikov Vladislav
  • 7,049
  • 9
  • 50
  • 87
  • 1
    possible duplicate of [How to remove .html from URL](http://stackoverflow.com/questions/5730092/how-to-remove-html-from-url) – TylerH Apr 16 '14 at 14:55
  • You have to understand what is variable in your query. I don't understand it now. You have this pattern: `^([0-9]+)-([^\/]+)?/page.html$`. URL, that you provided (`item-name123/page.html`) doesn't match this regexp. This will match: `1-item/page.html` or this: `123-sdfdfs`, and also this: `1-/page.html;` but not your url. This rule will work for your url: `RewriteRule ^(?:[A-Za-z0-9]+-)?([0-9]+)/page.html$ page.php?id=$1 [nc,qsa]`. Not that 1st group is non-capture. – Sharikov Vladislav Apr 17 '14 at 11:51

1 Answers1

0

Firstly, mod rewrite rule has next structure: RewriteRule Pattern Substitution [flags]

Pattern is a perl compatible regular expression.

The Substitution of a rewrite rule is the string that replaces the original URL-path that was matched by Pattern.

source

So, each (..) block in pattern refers to variable in substitution. In your rewriterule you have 2 groups of brackets, but only one variable in real url, what you want to refer to.

Also, your regular expression is not valid. You have to escape some symbols like \ or ..

You rewrite rule pattern has to be at least like this:

^([0-9]+)-([^\/]+)?\/page\.html$

Answer for your question. I assume this will work:

RewriteRule ^page/?$ index.php?action=page_action [L]

How can I transform it to be "www.site.com/page/abc"

Use this:

RewriteRule ^page/([A-Za-z0-9-]+)/?$ index.php?action=page_action&page=$1 [L] // $1 refers to (..) in pattern

UPDATE

Try to add flag [L] at the end each row and tell me about result.

It is strange, that my code didn't help you. Just tried this and this worked for me. Both with flag and without flag (without flag he redirected me to page from the substitution.

Sharikov Vladislav
  • 7,049
  • 9
  • 50
  • 87
  • It's great to see your reply. But that code you provided doesn't work. it gives this error "Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request." – Janice Simpova Apr 16 '14 at 16:08
  • I updated my code everywhere, firstly. Also, I tried this rule on my localhost and it is working properly. Can you provide full code of your `.htaccess` file? – Sharikov Vladislav Apr 16 '14 at 16:47