Allow URLs with Dashes on azure websites

218 Views Asked by At

I am trying to make an SEO friendly link for a downloads page using codeigniter hosted on Azure Websites, now this is working:

www.example.com/downloads/viewfile/34

now when i generated this link :

www.example.com/downloads/viewfile/my-nice-file-name-34

the Url rewrite works great locally on a WAMP server, but when deployed to the remote (Azure Webites IIS ?) it gives the error:

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

I believe that the cause is: dash symbols are not allowed on IIS but is there a way arround ?

2

There are 2 best solutions below

0
On

After all, i found out that its not the dash symbols that are causing the problem, but the words in the url itself

like yesterday i had www.example.com/downloads/viewfile/example-file-34 to some reason, having your domain-name in the url segments makes that error apear, so i simply replaced "mydomain" into nothing before generating the Url segment

$fileName = str_replace('mydomain','',$fileName);
return url_title($fileName.$fileId);

Now the same link above is www.example.com/downloads/viewfile/file-34 and its working fine.

i also noticed that same behavior is experienced when using some words like : ajax, json.

I hope this would be helful to somone.

0
On

In your routes.php file

Find

$route['translate_uri_dashes'] = FALSE;

Replace with

$route['translate_uri_dashes'] = TRUE;

You may need to look also into

URI Routing Codeigniter 3

http://www.codeigniter.com/user_guide/general/routing.html

Codeigniter 2 URI Routing

http://www.codeigniter.com/userguide2/general/routing.html