Dear Programmers,

I want to change accent characters in my smart URL to non-accent characters... For example : www.mysite.com/123/békítő to www.mysite.com/123/bekito.

Is it possible through .htaccess? Here is my current .htaccess

DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
</IfModule>

# Google Analytics Integration - Added by cPanel.
<IfModule mod_substitute.c>
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|(<script src='/google_analytics_auto.js'></script>)?</head>|<script src='/google_analytics_auto.js'></script></head>|i"
</IfModule>
# END Google Analytics Integration 

Thanks in advance,

Tibor

Member Avatar for LastMitch

@tibormarias

I want to change accent characters in my smart URL to non-accent characters... For example : www.mysite.com/123/békítő to www.mysite.com/123/bekito.

I think you know most RewriteRule are usually trial & error just to get the right match.

Try this:

RewriteRule ^([a-zA-Z0-9_'-]+)/(.*)$index.php?qa-rewrite=$0{QUERY_STRING} [L]

Let me know how it goes.

Thanks for your kind reply, but unfortunately it didn't work. I still get the following URL www.mysite.com/windows-8-%C3%A9s etc.

Member Avatar for LastMitch

@tibormarias

Thanks for your kind reply, but unfortunately it didn't work. I still get the following URL www.mysite.com/windows-8-%C3%A9s etc.

That's way off. By the way, what language is this békítő?

:) Hungarian. Békítő is someone who wants peace. But it was just an example for an accentful word.

Member Avatar for diafol

I don't think you can change accented chars to non accented equivalents via .htaccess. I think it would be relatively trivial for a redirect in php, but that may cause other problems, depending what you want from it.

Showing the pretty url is one thing, getting the data from the rewritten url may be something else. e.g. Depending on your rewrite:

www.example.com/tania/ 

could mean

www.example.com/index.php?id=tania
www.example.com/index.php?id=tània
www.example.com/index.php?id=tânià
www.example.com/index.php?id=tàniâ

etc. So if you need to make use of $_GET['id'] in that page, it could give you problems. Perhaps I've got the wrong end of the stick here. Stripping accents - to me - seems to be a one-way conversion.

Member Avatar for LastMitch

@tibormarias

:) Hungarian. Békítő is someone who wants peace. But it was just an example for an accentful word.

That's cool. That's a good word to used.

I agree with diafol. I was also playing around with it. diafol show some nice examples of the url.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.