Replaced id urls with title dynamic to CodeIgniter

I can replaced urls bottom together, Like:

http://localhost/zig-co/blog?id=7

to

http://localhost/zig-co/miniblog/7

with this:

RewriteEngine on
RewriteRule ^miniblog/([0-9]+)/?$ blog?id=$1 [NC,L]

but can not replaced urls bottom together, Like:

http://localhost/zig-co/blog?id=7

to

http://localhost/zig-co/miniblog/کت-و-شلوار

with this:

RewriteEngine on
RewriteRule ^miniblog/(.*)/?$ blog?url=$1 [NC,L]

do you can help me or guidance me?

You can’t, because Apache doesn’t know کت-و-شلوار and 7 are related.

Take a look at this thread: http://www.sitepoint.com/forums/apache-configuration-199/rewriting-get-variables-htaccess-753522.html

what is difference codes?


RewriteEngine on
#this is not work
RewriteRule ^miniblog/(.*)/?$ blog?url=$1 [L]    # Handle product requests

#worked
RewriteRule ^([a-z0-9_-]+)\\.html$ index.php/page/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\\.php|asset|robots\\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

with:


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^es/([a-zA-Z0-9-]+)$ article-spanish.php?article=$1 [L] 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9-]+)$ article-spanish.php?article=$1 [L]

The two are the same!?(my word is persian)

It’s not about the code, it’s what the code does. You want Apache to somehow translate کت-و-شلوار to id 7, so your php script can load article 7.
However Apache can’t do that, because it does not know that article کت-و-شلوار has id 7.
In the other thread we’re using the title of the article in the URL as well, so the problem doesn’t occur; in the other thread we rewrite from /کت-و-شلوار to /article.php?article=کت-و-شلوار instead of from /کت-و-شلوار to /article.php?acticle=7.
Do you see the difference?

ok, i purpose is rewrite from /کت-و-شلوار to /article.php
may you bad understand my purpose…
you sitepoint.com/forums considered that title to url. like:
title:

[B]replaced id urls title dynamic codeigniter[/B]

url:

http://www.sitepoint.com/forums/apache-configuration-199/[B]replaced-id-urls-title-dynamic-codeigniter[/B]-765127.html

difference is to letters persian and english…

Oh no, I completely understand what you want to do, but it can’t be done …

You can’t rewrite from /کت-و-شلوار to /article.php?id=7. It’s impossible, because Apache doesn’t know that کت-و-شلوار is article id 7, only PHP knows that, but Apache can’t ask PHP (unless you use a RewriteMap, but most hosts don’t allow you to do this).

What you could do is rewrite from /کت-و-شلوار to /article.php?url=کت-و-شلوار , but as we’ve seen in the other thread that doesn’t work because Apache screws up the encoding.

The only option I see now is that you could rewrite from say /7/کت-و-شلوار to /article.php?id=7, but that’s about it …

Before anything, You can test this:
http://www.binboy.gigfa.com/publish.php => can rewrite from /کت-و-شلوار to /article.php?id=7

Is not it?

No, it can not.

Ok,my url is /blog?id=7 no /article.php?id=7. please tell me a example with php and Apache…

Thanks!


RewriteRule ^([0-9]*)/(.*)$ blog?id=$1

Thank you very much, it worked
Which is better for SEO URLs?:
1)


/7/کت-و-شلوار


/7-کت-و-شلوار

I think the second one, but I’m not 100% sure