Mobile app version of vmapp.org
Login or Join
Berumen354

: How do I redirect an English language URL to an Arabic language URL? I have a link that's currently formatted like this: http://example.com/news/view/1.html I want to it redirect it to: http://example.com/خبر/عنوان-ا

@Berumen354

Posted in: #Htaccess #ModRewrite #Php #Url

I have a link that's currently formatted like this:
example.com/news/view/1.html

I want to it redirect it to:
example.com/خبر/عنوان-الخبر

where خبر is equal to news and
عنوان-الخبر is the title of the news page. I want ro do it using .htaccess, and provide a permanent 301 redirect for the old URLs.

Do I need to edit the PHP source at all to accomplish this?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Berumen354

2 Comments

Sorted by latest first Latest Oldest Best

 

@Debbie626

I don't know if you have to edit the PHP source, I suppose not.

I'd try do that with mod_rewrite:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^news/view/1.html$ /خبر/عنوان-الخبر [R=301,L]

10% popularity Vote Up Vote Down


 

@Miguel251

If it's a one off you just make sure your terminal is in UTF-8 mode, then paste the Arabic into a RedirectMatch as normal.

RedirectMatch permanent ^/news/view/1.html /خبر/عنوان-الخبر


If you wanted it dynamic (i.e. some database which lets you know the title of 1.html) then yes, that would need some PHP.

But if you are saying that 1.html is actually the correct URL, and you just want to change the text that appears in the browser address bar, I don't think that can be done

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme